From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: patches@linaro.org
Subject: [Qemu-devel] [PATCH 1/3] hw/misc/arm_sysctl: Fix bad boundary check on mb clock accesses
Date: Mon, 17 Feb 2014 14:37:32 +0000 [thread overview]
Message-ID: <1392647854-8067-2-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1392647854-8067-1-git-send-email-peter.maydell@linaro.org>
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 <peter.maydell@linaro.org>
---
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;
--
1.8.5
next prev parent reply other threads:[~2014-02-17 14:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-17 14:37 [Qemu-devel] [PATCH 0/3] ARM: three easy patches for coverity-reported issues Peter Maydell
2014-02-17 14:37 ` Peter Maydell [this message]
2014-02-17 14:37 ` [Qemu-devel] [PATCH 2/3] hw/net/stellaris_enet: Avoid unintended sign extension Peter Maydell
2014-02-17 14:37 ` [Qemu-devel] [PATCH 3/3] hw/timer/arm_timer: Avoid array overrun for bad addresses Peter Maydell
2014-02-17 18:59 ` [Qemu-devel] [PATCH 0/3] ARM: three easy patches for coverity-reported issues Paolo Bonzini
2014-02-18 1:02 ` Andreas Färber
2014-02-18 9:46 ` Peter Maydell
2014-02-18 10:13 ` Andreas Färber
2014-02-18 11:09 ` Peter Maydell
2014-02-18 11:16 ` Paolo Bonzini
2014-02-18 11:22 ` Peter Maydell
2014-02-18 11:23 ` Paolo Bonzini
2014-02-18 12:17 ` Alexander Graf
2014-02-18 12:37 ` Peter Maydell
2014-02-18 12:51 ` Alexander Graf
2014-02-18 12:53 ` Andreas Färber
2014-02-18 12:56 ` Alexander Graf
2014-02-18 12:44 ` Andreas Färber
2014-02-18 13:05 ` Peter Maydell
2014-02-18 13:53 ` Paolo Bonzini
2014-02-21 7:24 ` [Qemu-devel] [Qemu-stable] " Michael Roth
2014-02-21 10:43 ` Paolo Bonzini
2014-02-24 15:41 ` [Qemu-devel] " Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1392647854-8067-2-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=patches@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).