Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] bootconfig: unclosed brace on reused key misattributed in
xbc_init_configs()
--
commit 9ef6591953493a8a81a45580cc486a9c5b6fe288
Author: Masami Hiramatsu (Google) [off-list ref]
bootconfig: Add multi-config ID helpers and xbc_init_configs() support
This commit adds helpers for parsing and selecting named bootconfig blocks
and introduces xbc_init_configs() to concatenate and parse multiple enabled
configs into a single XBC tree.
quoted hunk ↗ jump to hunk
diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index 9ae9a215b1da3..fe27e72c9ee54 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -1134,12 +1129,219 @@ static int __init xbc_parse_tree(void)
} while (!ret);
if (!ret) {
- while (p < xbc_data + xbc_data_size - 1 && *p == '\0')
+ while (p < data + size && *p == '\0')
p++;
- if (p < xbc_data + xbc_data_size - 1)
+ if (p < data + size)
ret = xbc_parse_error("Unexpected data after null character", p);
}
+ if (!ret && brace_index) {
+ n = &xbc_nodes[open_brace[brace_index - 1]];
+ ret = xbc_parse_error("Brace is not closed",
+ xbc_node_get_data(n));
+ }
+
return ret;
}
[Severity: Medium]
Can an unclosed brace in a later config be misattributed to an earlier
config in xbc_init_configs()?
When a subsequent config reopens a key that was already defined in an
earlier config (for example, top-level "kernel {") and omits the closing
brace, __xbc_add_key() reuses the existing struct xbc_node from the
earlier config without updating node->data:
lib/bootconfig.c:__xbc_add_key() {
...
node = find_match_node(node, data);
if (node) {
last_parent = node;
} else {
...
}
Because xbc_node_get_data(n) still points into the earlier config's slice
of xbc_data, xbc_parse_error() sets xbc_err_pos to an offset within that
earlier slice. The error-mapping loop in xbc_init_configs() then reports
the earlier config's index in *err_idx and its offset in *epos instead of
blaming the config that left the brace unclosed.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127144614.61194-1-mhiramat@kernel.org?part=1