From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master] of: fdt: refuse / in property and node names
Date: Thu, 12 Mar 2026 17:03:54 +0100 [thread overview]
Message-ID: <20260312160433.194560-1-a.fatoum@pengutronix.de> (raw)
/ 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
next reply other threads:[~2026-03-12 16:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 16:03 Ahmad Fatoum [this message]
2026-03-13 11:13 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260312160433.194560-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox