All of lore.kernel.org
 help / color / mirror / Atom feed
From: "liqsub1"<liqsub1@163.com>
To: P J P <ppandit@redhat.com>, Qemu Developers <qemu-devel@nongnu.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Moguofang <moguofang@huawei.com>,
	Prasad J Pandit <pjp@fedoraproject.org>
Subject: Re: [Qemu-devel] [PATCH 1/3] arm: check bit index before use
Date: Mon, 22 Oct 2018 20:15:15 +0800	[thread overview]
Message-ID: <4d7675ee.374e.1669bb366e4.Coremail.liqsub1@163.com> (raw)
In-Reply-To: <20181022120908.13285-1-ppandit@redhat.com>



2018-10-22 

liqsub1 



发件人:P J P <ppandit@redhat.com>
发送时间:2018-10-23 01:39
主题:[Qemu-devel] [PATCH 1/3] arm: check bit index before use
收件人:"Qemu Developers"<qemu-devel@nongnu.org>
抄送:"Peter Maydell"<peter.maydell@linaro.org>,"Moguofang"<moguofang@huawei.com>,"Prasad J Pandit"<pjp@fedoraproject.org>

From: Prasad J Pandit <pjp@fedoraproject.org> 

While performing gpio write via strongarm_gpio_handler_update 
routine, the 'bit' index could access beyond s->handler[28] array. 
Add check to avoid OOB access. 

Reported-by: Moguofang <moguofang@huawei.com> 
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> 
--- 
 hw/arm/strongarm.c | 4 +++- 
 1 file changed, 3 insertions(+), 1 deletion(-) 

diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c 
index ec2627374d..3dda75feaf 100644 
--- a/hw/arm/strongarm.c 
+++ b/hw/arm/strongarm.c 
@@ -532,7 +532,9 @@ static void strongarm_gpio_handler_update(StrongARMGPIOInfo *s) 
  
     for (diff = s->prev_level ^ level; diff; diff ^= 1 << bit) { 
         bit = ctz32(diff); 
-        qemu_set_irq(s->handler[bit], (level >> bit) & 1); 
+        if (bit < sizeof(s->handler) / sizeof(s->handler[0])) { 

Hello Prasad,
Maybe you can use ARRAY_SIZE here.

Thanks,
Li Qiang

+            qemu_set_irq(s->handler[bit], (level >> bit) & 1); 
+        } 
     } 



  
     s->prev_level = level; 
--  
2.17.2 

  reply	other threads:[~2018-10-22 12:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-22 12:09 [Qemu-devel] [PATCH 1/3] arm: check bit index before use P J P
2018-10-22 12:15 ` liqsub1 [this message]
2018-10-22 18:14   ` P J P
2018-10-26  9:33 ` Paolo Bonzini

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=4d7675ee.374e.1669bb366e4.Coremail.liqsub1@163.com \
    --to=liqsub1@163.com \
    --cc=moguofang@huawei.com \
    --cc=peter.maydell@linaro.org \
    --cc=pjp@fedoraproject.org \
    --cc=ppandit@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.