* [PATCH] of: fdt: fix off-by-one error in unflatten_dt_nodes()
@ 2022-08-13 20:34 Sergey Shtylyov
2022-08-16 17:29 ` Rob Herring
0 siblings, 1 reply; 2+ messages in thread
From: Sergey Shtylyov @ 2022-08-13 20:34 UTC (permalink / raw)
To: Rob Herring, Frank Rowand, devicetree
Commit 78c44d910d3e ("drivers/of: Fix depth when unflattening devicetree")
forgot to fix up the depth check in the loop body in unflatten_dt_nodes()
which makes it possible to overflow the nps[] buffer...
Found by Linux Verification Center (linuxtesting.org) with the SVACE static
analysis tool.
Fixes: 78c44d910d3e ("drivers/of: Fix depth when unflattening devicetree")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
The patch is against the 'master' branch of Rob Herring's 'linux-git' repo...
drivers/of/fdt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux/drivers/of/fdt.c
===================================================================
--- linux.orig/drivers/of/fdt.c
+++ linux/drivers/of/fdt.c
@@ -314,7 +314,7 @@ static int unflatten_dt_nodes(const void
for (offset = 0;
offset >= 0 && depth >= initial_depth;
offset = fdt_next_node(blob, offset, &depth)) {
- if (WARN_ON_ONCE(depth >= FDT_MAX_DEPTH))
+ if (WARN_ON_ONCE(depth >= FDT_MAX_DEPTH - 1))
continue;
if (!IS_ENABLED(CONFIG_OF_KOBJ) &&
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] of: fdt: fix off-by-one error in unflatten_dt_nodes()
2022-08-13 20:34 [PATCH] of: fdt: fix off-by-one error in unflatten_dt_nodes() Sergey Shtylyov
@ 2022-08-16 17:29 ` Rob Herring
0 siblings, 0 replies; 2+ messages in thread
From: Rob Herring @ 2022-08-16 17:29 UTC (permalink / raw)
To: Sergey Shtylyov; +Cc: Rob Herring, devicetree, Frank Rowand
On Sat, 13 Aug 2022 23:34:16 +0300, Sergey Shtylyov wrote:
> Commit 78c44d910d3e ("drivers/of: Fix depth when unflattening devicetree")
> forgot to fix up the depth check in the loop body in unflatten_dt_nodes()
> which makes it possible to overflow the nps[] buffer...
>
> Found by Linux Verification Center (linuxtesting.org) with the SVACE static
> analysis tool.
>
> Fixes: 78c44d910d3e ("drivers/of: Fix depth when unflattening devicetree")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>
> ---
> The patch is against the 'master' branch of Rob Herring's 'linux-git' repo...
>
> drivers/of/fdt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-16 17:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-13 20:34 [PATCH] of: fdt: fix off-by-one error in unflatten_dt_nodes() Sergey Shtylyov
2022-08-16 17:29 ` Rob Herring
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.