[Qemu-devel] [PATCH v1] display: limit irq handler index to TC6393XB_GPIOS

P J P posted 1 patch 6 years, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20171212041539.25700-1-ppandit@redhat.com
Test checkpatch passed
Test docker passed
Test ppc passed
Test s390x passed
hw/display/tc6393xb.c | 1 +
1 file changed, 1 insertion(+)
[Qemu-devel] [PATCH v1] display: limit irq handler index to TC6393XB_GPIOS
Posted by P J P 6 years, 4 months ago
From: Prasad J Pandit <pjp@fedoraproject.org>

The ctz32() routine could return value greater than
TC6393XB_GPIOS=16. This could lead to an OOB array access.
Mask 'level' to avoid it.

Reported-by: Moguofang <moguofang@huawei.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 hw/display/tc6393xb.c | 1 +
 1 file changed, 1 insertion(+)

Update: mask 'level' value to TC6393XB_GPIOS=16
  -> https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg01685.html

diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c
index 74d10af3d4..0ae63605f0 100644
--- a/hw/display/tc6393xb.c
+++ b/hw/display/tc6393xb.c
@@ -172,6 +172,7 @@ static void tc6393xb_gpio_handler_update(TC6393xbState *s)
     int bit;
 
     level = s->gpio_level & s->gpio_dir;
+    level &= MAKE_64BIT_MASK(0, TC6393XB_GPIOS);
 
     for (diff = s->prev_level ^ level; diff; diff ^= 1 << bit) {
         bit = ctz32(diff);
-- 
2.13.6


Re: [Qemu-devel] [PATCH v1] display: limit irq handler index to TC6393XB_GPIOS
Posted by Peter Maydell 6 years, 4 months ago
On 12 December 2017 at 04:15, P J P <ppandit@redhat.com> wrote:
> From: Prasad J Pandit <pjp@fedoraproject.org>
>
> The ctz32() routine could return value greater than
> TC6393XB_GPIOS=16. This could lead to an OOB array access.
> Mask 'level' to avoid it.
>
> Reported-by: Moguofang <moguofang@huawei.com>
> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
> ---
>  hw/display/tc6393xb.c | 1 +
>  1 file changed, 1 insertion(+)
>
> Update: mask 'level' value to TC6393XB_GPIOS=16
>   -> https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg01685.html
>
> diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c
> index 74d10af3d4..0ae63605f0 100644
> --- a/hw/display/tc6393xb.c
> +++ b/hw/display/tc6393xb.c
> @@ -172,6 +172,7 @@ static void tc6393xb_gpio_handler_update(TC6393xbState *s)
>      int bit;
>
>      level = s->gpio_level & s->gpio_dir;
> +    level &= MAKE_64BIT_MASK(0, TC6393XB_GPIOS);
>
>      for (diff = s->prev_level ^ level; diff; diff ^= 1 << bit) {
>          bit = ctz32(diff);

Thanks; applied to target-arm.next for 2.12.

-- PMM