* [PATCH] hw/gpio: npcm7xx: fixup out-of-bounds access
@ 2025-02-26 2:46 Patrick Venture
2025-02-26 7:03 ` Philippe Mathieu-Daudé
2025-03-03 14:11 ` Peter Maydell
0 siblings, 2 replies; 4+ messages in thread
From: Patrick Venture @ 2025-02-26 2:46 UTC (permalink / raw)
To: peter.maydell; +Cc: qemu-arm, qemu-devel, kfting, wuhaotsh, Patrick Venture
The reg isn't validated to be a possible register before
it's dereferenced for one case. The mmio space registered
for the gpio device is 4KiB but there aren't that many
registers in the struct.
Google-Bug-Id: 397469048
Change-Id: I2fb8d0d3d41422baab22e8fc7e9fadd0f2ee7068
Signed-off-by: Patrick Venture <venture@google.com>
---
hw/gpio/npcm7xx_gpio.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/hw/gpio/npcm7xx_gpio.c b/hw/gpio/npcm7xx_gpio.c
index 23e67424c9..2916056fae 100644
--- a/hw/gpio/npcm7xx_gpio.c
+++ b/hw/gpio/npcm7xx_gpio.c
@@ -220,8 +220,6 @@ static void npcm7xx_gpio_regs_write(void *opaque, hwaddr addr, uint64_t v,
return;
}
- diff = s->regs[reg] ^ value;
-
switch (reg) {
case NPCM7XX_GPIO_TLOCK1:
case NPCM7XX_GPIO_TLOCK2:
@@ -242,6 +240,7 @@ static void npcm7xx_gpio_regs_write(void *opaque, hwaddr addr, uint64_t v,
case NPCM7XX_GPIO_PU:
case NPCM7XX_GPIO_PD:
case NPCM7XX_GPIO_IEM:
+ diff = s->regs[reg] ^ value;
s->regs[reg] = value;
npcm7xx_gpio_update_pins(s, diff);
break;
--
2.48.1.658.g4767266eb4-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/gpio: npcm7xx: fixup out-of-bounds access
2025-02-26 2:46 [PATCH] hw/gpio: npcm7xx: fixup out-of-bounds access Patrick Venture
@ 2025-02-26 7:03 ` Philippe Mathieu-Daudé
2025-02-26 16:16 ` Patrick Venture
2025-03-03 14:11 ` Peter Maydell
1 sibling, 1 reply; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-26 7:03 UTC (permalink / raw)
To: Patrick Venture, peter.maydell; +Cc: qemu-arm, qemu-devel, kfting, wuhaotsh
On 26/2/25 03:46, Patrick Venture wrote:
> The reg isn't validated to be a possible register before
> it's dereferenced for one case. The mmio space registered
> for the gpio device is 4KiB but there aren't that many
> registers in the struct.
>
> Google-Bug-Id: 397469048
> Change-Id: I2fb8d0d3d41422baab22e8fc7e9fadd0f2ee7068
^ Both lines are irrelevant on mainstream git history, otherwise:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Cc: qemu-stable@nongnu.org
Fixes: 526dbbe0874 ("hw/gpio: Add GPIO model for Nuvoton NPCM7xx")
> Signed-off-by: Patrick Venture <venture@google.com>
> ---
> hw/gpio/npcm7xx_gpio.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/gpio: npcm7xx: fixup out-of-bounds access
2025-02-26 7:03 ` Philippe Mathieu-Daudé
@ 2025-02-26 16:16 ` Patrick Venture
0 siblings, 0 replies; 4+ messages in thread
From: Patrick Venture @ 2025-02-26 16:16 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: peter.maydell, qemu-arm, qemu-devel, kfting, wuhaotsh
[-- Attachment #1: Type: text/plain, Size: 945 bytes --]
On Tue, Feb 25, 2025 at 11:04 PM Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:
> On 26/2/25 03:46, Patrick Venture wrote:
> > The reg isn't validated to be a possible register before
> > it's dereferenced for one case. The mmio space registered
> > for the gpio device is 4KiB but there aren't that many
> > registers in the struct.
> >
> > Google-Bug-Id: 397469048
> > Change-Id: I2fb8d0d3d41422baab22e8fc7e9fadd0f2ee7068
>
> ^ Both lines are irrelevant on mainstream git history, otherwise:
>
Thanks, sorry, I was in a hurry last night to send this out and forgot to
strip them.
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>
> Cc: qemu-stable@nongnu.org
> Fixes: 526dbbe0874 ("hw/gpio: Add GPIO model for Nuvoton NPCM7xx")
>
> > Signed-off-by: Patrick Venture <venture@google.com>
> > ---
> > hw/gpio/npcm7xx_gpio.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
>
>
[-- Attachment #2: Type: text/html, Size: 1717 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/gpio: npcm7xx: fixup out-of-bounds access
2025-02-26 2:46 [PATCH] hw/gpio: npcm7xx: fixup out-of-bounds access Patrick Venture
2025-02-26 7:03 ` Philippe Mathieu-Daudé
@ 2025-03-03 14:11 ` Peter Maydell
1 sibling, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2025-03-03 14:11 UTC (permalink / raw)
To: Patrick Venture; +Cc: qemu-arm, qemu-devel, kfting, wuhaotsh
On Wed, 26 Feb 2025 at 02:46, Patrick Venture <venture@google.com> wrote:
>
> The reg isn't validated to be a possible register before
> it's dereferenced for one case. The mmio space registered
> for the gpio device is 4KiB but there aren't that many
> registers in the struct.
>
> Google-Bug-Id: 397469048
> Change-Id: I2fb8d0d3d41422baab22e8fc7e9fadd0f2ee7068
> Signed-off-by: Patrick Venture <venture@google.com>
Applied to target-arm.next (with commit message tweaks
as per Philippe's email), thanks.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-03-03 14:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-26 2:46 [PATCH] hw/gpio: npcm7xx: fixup out-of-bounds access Patrick Venture
2025-02-26 7:03 ` Philippe Mathieu-Daudé
2025-02-26 16:16 ` Patrick Venture
2025-03-03 14:11 ` Peter Maydell
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).