Linux Trace Kernel
 help / color / mirror / Atom feed
* [PATCH 0/4] bootconfig: Fix tree verification, key composition, and cmdline rendering bugs
@ 2026-11-22  1:01 Masami Hiramatsu (Google)
  2026-11-22  1:01 ` [PATCH 1/4] bootconfig: Fix xbc_verify_tree() to check subkeys of valued keys Masami Hiramatsu (Google)
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Masami Hiramatsu (Google) @ 2026-11-22  1:01 UTC (permalink / raw)
  To: Masami Hiramatsu, Steven Rostedt, Andrew Morton
  Cc: linux-kernel, linux-trace-kernel

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@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-22  1:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 1/4] bootconfig: Fix xbc_verify_tree() to check subkeys of valued keys Masami Hiramatsu (Google)
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)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox