* [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
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