[PATCH 1/4] bootconfig: Fix xbc_verify_tree() to check subkeys of valued keys

From: Masami Hiramatsu (Google)

Date: Sat Nov 21 2026 - 20:01:40 EST


From: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>

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@xxxxxxxxxxxxxxx
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
---
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)