mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] of: fdt: refuse / in property and node names
@ 2026-03-12 16:03 Ahmad Fatoum
  2026-03-13 11:13 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-03-12 16:03 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

/ is used as delimiter between nodes, so seeing it in a device node name
hints at something fishy going on, so refuse that outright.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/of/fdt.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 13fb4b5c099e..1648f4c2d945 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -67,6 +67,14 @@ static inline bool is_reserved_name(const char *name)
 	return *name == '$';
 }
 
+static inline bool is_allowed_input_name(const char *name)
+{
+	/* We are stricter on input than on output, because we assume barebox
+	 * code won't attempt naming nodes bogously.
+	 */
+	return !is_reserved_name(name) && !strchr(name, '/');
+}
+
 static int of_reservemap_num_entries(const struct fdt_header *fdt)
 {
 	/*
@@ -248,7 +256,7 @@ static struct device_node *__of_unflatten_dtb(const void *infdt, int size,
 				node = root;
 			} else {
 				/* Only the root node may have an empty name */
-				if (!*pathp || is_reserved_name(pathp)) {
+				if (!*pathp || !is_allowed_input_name(pathp)) {
 					ret = -EINVAL;
 					goto err;
 				}
@@ -285,7 +293,7 @@ static struct device_node *__of_unflatten_dtb(const void *infdt, int size,
 			nodep = fdt_prop->data;
 
 			name = dt_string(&f, dt_strings, fdt32_to_cpu(fdt_prop->nameoff));
-			if (!name || !node ||  is_reserved_name(name)) {
+			if (!name || !node ||  !is_allowed_input_name(name)) {
 				ret = -ESPIPE;
 				goto err;
 			}
-- 
2.47.3




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH master] of: fdt: refuse / in property and node names
  2026-03-12 16:03 [PATCH master] of: fdt: refuse / in property and node names Ahmad Fatoum
@ 2026-03-13 11:13 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-03-13 11:13 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Thu, 12 Mar 2026 17:03:54 +0100, Ahmad Fatoum wrote:
> / is used as delimiter between nodes, so seeing it in a device node name
> hints at something fishy going on, so refuse that outright.
> 
> 

Applied, thanks!

[1/1] of: fdt: refuse / in property and node names
      https://git.pengutronix.de/cgit/barebox/commit/?id=aca01795056d (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:[~2026-03-13 11:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-12 16:03 [PATCH master] of: fdt: refuse / in property and node names Ahmad Fatoum
2026-03-13 11:13 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox