bootconfig: Fix tree verification, key composition, and cmdline rendering bugs
Get series with b4
b4 am 179530928294.109991.3079999508446852151.stgit@devnote2Versions newest first
- v1 Latest4 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | bootconfig: Fix xbc_verify_tree() to check subkeys of valued keyslib/ | +2 | 0 replies | |
| 2/4 | bootconfig: Fix xbc_node_compose_key_after() for value nodeslib/ | +3 | 0 replies | |
| 3/4 | bootconfig: Avoid out-of-bounds pointer arithmetic in xbc_snprint_cmdline_filter()lib/ | +4 | 0 replies | |
| 4/4 | tools/bootconfig: Add tests for unclosed brace position and mixed-kv limitstools/ | +33 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/4] bootconfig: Fix tree verification, key composition, and cmdline rendering bugs
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) <[email protected]>