* [PATCH] of/irq: Refer to actual buffer size in of_irq_parse_one()
@ 2024-08-20 12:16 Geert Uytterhoeven
2024-08-26 13:45 ` Rob Herring (Arm)
0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2024-08-20 12:16 UTC (permalink / raw)
To: Stefan Wiehler, Rob Herring, Saravana Kannan
Cc: devicetree, linux-kernel, Geert Uytterhoeven
Replace two open-coded calculations of the buffer size by invocations of
sizeof() on the buffer itself, to make sure the code will always use the
actual buffer size.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
If you think this warrants a Fixes-tag:
Fixes: b739dffa5d570b41 ("of/irq: Prevent device address out-of-bounds read in interrupt map walk")
---
drivers/of/irq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index cc30b471e446045a..36351ad6115eb10e 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -357,8 +357,8 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar
addr = of_get_property(device, "reg", &addr_len);
/* Prevent out-of-bounds read in case of longer interrupt parent address size */
- if (addr_len > (3 * sizeof(__be32)))
- addr_len = 3 * sizeof(__be32);
+ if (addr_len > sizeof(addr_buf))
+ addr_len = sizeof(addr_buf);
if (addr)
memcpy(addr_buf, addr, addr_len);
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] of/irq: Refer to actual buffer size in of_irq_parse_one()
2024-08-20 12:16 [PATCH] of/irq: Refer to actual buffer size in of_irq_parse_one() Geert Uytterhoeven
@ 2024-08-26 13:45 ` Rob Herring (Arm)
0 siblings, 0 replies; 2+ messages in thread
From: Rob Herring (Arm) @ 2024-08-26 13:45 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: devicetree, linux-kernel, Saravana Kannan, Stefan Wiehler
On Tue, 20 Aug 2024 14:16:53 +0200, Geert Uytterhoeven wrote:
> Replace two open-coded calculations of the buffer size by invocations of
> sizeof() on the buffer itself, to make sure the code will always use the
> actual buffer size.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> If you think this warrants a Fixes-tag:
>
> Fixes: b739dffa5d570b41 ("of/irq: Prevent device address out-of-bounds read in interrupt map walk")
> ---
> drivers/of/irq.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
Applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-26 13:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-20 12:16 [PATCH] of/irq: Refer to actual buffer size in of_irq_parse_one() Geert Uytterhoeven
2024-08-26 13:45 ` Rob Herring (Arm)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®