* [PATCH v2] of: fdt: fix overflow caused by fdt_prop extending beyond fdt
@ 2024-11-19 21:26 Abdelrahman Youssef
2024-11-25 8:24 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Abdelrahman Youssef @ 2024-11-19 21:26 UTC (permalink / raw)
To: barebox; +Cc: Abdelrahman Youssef, Ahmad Fatoum
While parsing FDT, fdt_prop sometimes extends beyond FDT resulting in
heap-overflow.
dt_ptr_ok() checks a pointer is within bounds of the FDT, so we can use it
here to fix the issue.
Suggested-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Abdelrahman Youssef <abdelrahmanyossef12@gmail.com>
---
drivers/of/fdt.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 75af1844f3..69c041cb89 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -257,6 +257,11 @@ static struct device_node *__of_unflatten_dtb(const void *infdt, int size,
case FDT_PROP:
fdt_prop = infdt + dt_struct;
+ if (!dt_ptr_ok(fdt, fdt_prop)) {
+ ret = -ESPIPE;
+ goto err;
+ }
+
len = fdt32_to_cpu(fdt_prop->len);
nodep = fdt_prop->data;
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] of: fdt: fix overflow caused by fdt_prop extending beyond fdt
2024-11-19 21:26 [PATCH v2] of: fdt: fix overflow caused by fdt_prop extending beyond fdt Abdelrahman Youssef
@ 2024-11-25 8:24 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-11-25 8:24 UTC (permalink / raw)
To: barebox, Abdelrahman Youssef; +Cc: Ahmad Fatoum
On Tue, 19 Nov 2024 23:26:04 +0200, Abdelrahman Youssef wrote:
> While parsing FDT, fdt_prop sometimes extends beyond FDT resulting in
> heap-overflow.
>
> dt_ptr_ok() checks a pointer is within bounds of the FDT, so we can use it
> here to fix the issue.
>
>
> [...]
Applied, thanks!
[1/1] of: fdt: fix overflow caused by fdt_prop extending beyond fdt
https://git.pengutronix.de/cgit/barebox/commit/?id=4e9331dd33be (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-25 8:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-19 21:26 [PATCH v2] of: fdt: fix overflow caused by fdt_prop extending beyond fdt Abdelrahman Youssef
2024-11-25 8:24 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox