From patchwork Mon Feb 17 14:37:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 24772 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f200.google.com (mail-pd0-f200.google.com [209.85.192.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EE10720468 for ; Mon, 17 Feb 2014 14:37:37 +0000 (UTC) Received: by mail-pd0-f200.google.com with SMTP id y10sf34258018pdj.3 for ; Mon, 17 Feb 2014 06:37:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=CWTx06jZc9R2IVQUfVRcEhWbwaBcZ+pXjjSrz8Km2eo=; b=AI6BFKJ5LO8yM6alSN+b69LBPL5LoRhaPNGrPd+qN6M/ga3XouyPzyoUVK5wGLGWyB nxkUjqax+EtVujBKq6It3v6DXvD90XGKx2+ZlFOYwubCQmlygl7bbUBtazm8faQYWhq/ mOropgbelWmgwag+kWtWSt6ooSDhsdjW2omahWNkTMDYdujTrgjtD2YSeN/n8Xo92qdT dQtE/iO8R2VprX4soXOiMkfoVQa8ID5Wg8g4qhqRM0auRk9rQNDoKt6ERRbYOrM4ksba dZHzq9I5QvaW4nYD2ru1qoktg7CBKL/5CZiOuAyYoEGNIf/iKHaROKiZtrUtAWGYKCb3 hLfg== X-Gm-Message-State: ALoCoQlPr7myYIsYBAkik87sVw3p/kFqIZGnwhQlWHr7zFVeFKtByXI+mlfP6XGcKGdgtP83022T X-Received: by 10.67.21.145 with SMTP id hk17mr10181741pad.35.1392647857200; Mon, 17 Feb 2014 06:37:37 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.103.118 with SMTP id x109ls924893qge.43.gmail; Mon, 17 Feb 2014 06:37:37 -0800 (PST) X-Received: by 10.220.10.2 with SMTP id n2mr12879902vcn.26.1392647857092; Mon, 17 Feb 2014 06:37:37 -0800 (PST) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id ks3si4499045vec.127.2014.02.17.06.37.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Feb 2014 06:37:37 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id le5so11834088vcb.16 for ; Mon, 17 Feb 2014 06:37:37 -0800 (PST) X-Received: by 10.52.160.233 with SMTP id xn9mr1257071vdb.48.1392647856999; Mon, 17 Feb 2014 06:37:36 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp143261vcz; Mon, 17 Feb 2014 06:37:36 -0800 (PST) X-Received: by 10.152.170.135 with SMTP id am7mr17845181lac.23.1392647855948; Mon, 17 Feb 2014 06:37:35 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id z4si25415241lal.134.2014.02.17.06.37.35 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 17 Feb 2014 06:37:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WFPKA-00026d-9Z; Mon, 17 Feb 2014 14:37:34 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org Subject: [PATCH 1/3] hw/misc/arm_sysctl: Fix bad boundary check on mb clock accesses Date: Mon, 17 Feb 2014 14:37:32 +0000 Message-Id: <1392647854-8067-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1392647854-8067-1-git-send-email-peter.maydell@linaro.org> References: <1392647854-8067-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Fix incorrect use of sizeof() rather than ARRAY_SIZE() to guard accesses into the mb_clock[] array, which was allowing a malicious guest to overwrite the end of the array. Signed-off-by: Peter Maydell --- hw/misc/arm_sysctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/misc/arm_sysctl.c b/hw/misc/arm_sysctl.c index 0fc26d2..3fad6f8 100644 --- a/hw/misc/arm_sysctl.c +++ b/hw/misc/arm_sysctl.c @@ -276,7 +276,7 @@ static bool vexpress_cfgctrl_read(arm_sysctl_state *s, unsigned int dcc, } break; case SYS_CFG_OSC: - if (site == SYS_CFG_SITE_MB && device < sizeof(s->mb_clock)) { + if (site == SYS_CFG_SITE_MB && device < ARRAY_SIZE(s->mb_clock)) { /* motherboard clock */ *val = s->mb_clock[device]; return true; @@ -324,7 +324,7 @@ static bool vexpress_cfgctrl_write(arm_sysctl_state *s, unsigned int dcc, switch (function) { case SYS_CFG_OSC: - if (site == SYS_CFG_SITE_MB && device < sizeof(s->mb_clock)) { + if (site == SYS_CFG_SITE_MB && device < ARRAY_SIZE(s->mb_clock)) { /* motherboard clock */ s->mb_clock[device] = val; return true;