The Linux Kernel Mailing List
 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 0/4] bootconfig: Fix tree verification, key composition, and cmdline rendering bugs
Date: Sun, 22 Nov 2026 10:01:23 +0900	[thread overview]
Message-ID: <179530928294.109991.3079999508446852151.stgit@devnote2> (raw)

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>

             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 Masami Hiramatsu (Google) [this message]
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)

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=179530928294.109991.3079999508446852151.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox