[PATCH 0/4] bootconfig: Fix tree verification, key composition, and cmdline rendering bugs
From: Masami Hiramatsu (Google)
Date: Sat Nov 21 2026 - 20:01:50 EST
Hi,
This series fixes bugs in the Extra Boot Config (bootconfig) parser and
tree query/rendering API (`lib/bootconfig.c`), and adds regression tests
to `tools/bootconfig/test-bootconfig.sh`. These issues were found while
formally modeling and verifying the bootconfig parser in Lean 4.
Summary of changes:
1. Fix `xbc_verify_tree()` to use `xbc_node_get_subkey()` instead of
`xbc_node_get_child()` when descending the key tree. Previously, if a
key node had both a value and subkeys, its first child was the value
node, causing `xbc_verify_tree()` to skip all subkeys under it and
bypass both `XBC_DEPTH_MAX` (16) and `XBC_KEYLEN_MAX` (256) checks.
2. Fix `xbc_node_compose_key_after()` for value nodes: climb all parent
value nodes in a loop (`while (node && xbc_node_is_value(node))`) so
that 2nd+ array value nodes resolve to their owning key node, and
perform `if (!node || node == root)` after climbing so that passing a
value node belonging to the subtree `@root` key node itself (e.g.
`foo = "val"` with `@root = xbc_find_node("foo")`) returns `-EINVAL`
rather than `0` with an untouched buffer.
3. Fix `xbc_snprint_cmdline_filter()` to pass
`buf && len < size ? buf + len : NULL` to `snprintf()`, avoiding
out-of-bounds pointer arithmetic (`buf + len` with `len > size`) when
`@buf` is non-NULL and the rendered output exceeds `@size`.
4. Add regression tests to `tools/bootconfig/test-bootconfig.sh` for
unclosed brace error position reporting and mixed value+subkey
depth/length limit enforcement.
Thank you,
---
Masami Hiramatsu (Google) (4):
bootconfig: Fix xbc_verify_tree() to check subkeys of valued keys
bootconfig: Fix xbc_node_compose_key_after() for value nodes
bootconfig: Avoid out-of-bounds pointer arithmetic in xbc_snprint_cmdline_filter()
tools/bootconfig: Add tests for unclosed brace position and mixed-kv limits
lib/bootconfig.c | 17 +++++++++--------
tools/bootconfig/test-bootconfig.sh | 33 +++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 8 deletions(-)
--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>