All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
To: Masami Hiramatsu <mhiramat@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: [PATCH 1/4] bootconfig: Fix xbc_verify_tree() to check subkeys of valued keys
Date: Sun, 22 Nov 2026 10:01:32 +0900	[thread overview]
Message-ID: <179530929234.109991.150550090881188440.stgit@devnote2> (raw)
In-Reply-To: <179530928294.109991.3079999508446852151.stgit@devnote2>

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

When a key node has both a value and subkeys, the value node is always
inserted as the first child of the key node (xbc_add_head_sibling()), and
subkeys follow as next siblings of that value node.

However, xbc_verify_tree() uses xbc_node_get_child(n) and checks
xbc_node_is_key(m) to descend into subkeys. When a key node has a value,
xbc_node_get_child(n) returns the value node, so xbc_node_is_key(m) is
false and xbc_verify_tree() completely skips verifying all subkeys under
that key. This allows subkeys under a valued key to bypass both the
XBC_DEPTH_MAX (16) and XBC_KEYLEN_MAX (256) checks during xbc_init(),
causing runtime -ERANGE failures in xbc_node_compose_key_after().

Use xbc_node_get_subkey(n) so that subkeys of mixed value+subkey nodes
are properly verified.

Fixes: e5efaeb8a8f5 ("bootconfig: Support mixing a value and subkeys under a key")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 lib/bootconfig.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index 948c8c10e4b9..026d88a65c5c 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -1058,8 +1058,8 @@ static int __init xbc_verify_tree(void)
 			return xbc_parse_error("Too long key length",
 				xbc_node_get_data(n));
 
-		m = xbc_node_get_child(n);
-		if (m && xbc_node_is_key(m)) {
+		m = xbc_node_get_subkey(n);
+		if (m) {
 			n = m;
 			depth++;
 			if (depth > XBC_DEPTH_MAX)


  reply	other threads:[~2026-11-22  1:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22  1:01 [PATCH 0/4] bootconfig: Fix tree verification, key composition, and cmdline rendering bugs Masami Hiramatsu (Google)
2026-11-22  1:01 ` Masami Hiramatsu (Google) [this message]
2026-11-22  1:01 ` [PATCH 2/4] bootconfig: Fix xbc_node_compose_key_after() for value nodes Masami Hiramatsu (Google)
2026-11-22  1:01 ` [PATCH 3/4] bootconfig: Avoid out-of-bounds pointer arithmetic in xbc_snprint_cmdline_filter() Masami Hiramatsu (Google)
2026-11-22  1:01 ` [PATCH 4/4] tools/bootconfig: Add tests for unclosed brace position and mixed-kv limits Masami Hiramatsu (Google)

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=179530929234.109991.150550090881188440.stgit@devnote2 \
    --to=mhiramat@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.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 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.