On Fri, 27 Nov 2026 15:11:05 +0000, sashiko-bot@kernel.org [off-list ref] wrote:
[Severity: Low]
Can this blame an earlier bootconfig block when a later overlay leaves a
brace unclosed on an existing key?
It seems that the same as the comment in the previous patch 1.
quoted
diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index fe27e72c9ee54..44177b7c08660 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -115,33 +115,54 @@ bool __init xbc_embedded_cmdline_applied(void)
}
#endif /* CONFIG_CMDLINE_FROM_BOOTCONFIG */
-/* parse_args() callback: flag when the "bootconfig" parameter is present. */
-static int __init bootconfig_optin(char *param, char *val,
- const char *unused, void *arg)
+struct xbc_cmdline_select_ctx {
+ struct xbc_config *cfgs;
+ int count;
+ bool seen;
+ bool active;
+ bool warn;
+};
+
+/* parse_args() callback: track opt-in and update enabled bootconfig entries. */
+static int __init xbc_cmdline_select_cb(char *param, char *val,
+ const char *unused, void *arg)
{
- if (!strcmp(param, "bootconfig"))
- *(bool *)arg = true;
+ struct xbc_cmdline_select_ctx *ctx = arg;
+
+ if (strcmp(param, "bootconfig"))
+ return 0;
+
+ if (!val) {
+ ctx->active = true;
+ } else if (*val == '\0') {
+ ctx->active = false;
+ } else if (*val == '+') {
+ if (!ctx->seen || val[1] != '\0')
+ ctx->active = true;
+ } else {
+ ctx->active = true;
+ }
+
+ if (ctx->cfgs)
+ __xbc_enable_configs(ctx->cfgs, ctx->count, val,
+ &ctx->seen, ctx->warn);
+ else
+ ctx->seen = true;
+
return 0;
}
[ ... ]
quoted
+bool __init bootconfig_cmdline_requested(const char *boot_cmdline, int *end_offset)
+{
+ struct xbc_config emb = { .name = "", .name_len = 0, .enabled = false };
+ const char *data;
+ size_t size;
+ bool active;
+
+ data = xbc_get_embedded_bootconfig(&size);
+ if (data && xbc_parse_id_header(data, size, &emb) < 0) {
+ emb.name = "";
+ emb.name_len = 0;
+ }
+
+ active = xbc_parse_cmdline_bootconfig(boot_cmdline, &emb, 1,
+ end_offset, false);
+ if (IS_ENABLED(CONFIG_BOOT_CONFIG_FORCE) && !active)
+ return true;
+
+ return active && emb.enabled;
+}
[Severity: Medium]
Does an unmatched bootconfig=<sel> parameter bypass
CONFIG_BOOT_CONFIG_FORCE=y instead of falling back to index 0?
Good catch!
xbc_cmdline_select_cb() sets ctx->active = true for any non-empty val even
when __xbc_enable_configs() finds no matching entry and leaves every
cfgs[i].enabled set to false. Because active (and bootconfig_found in
setup_boot_config()) is true while no config is enabled, the
CONFIG_BOOT_CONFIG_FORCE fallback (!active / !bootconfig_found) is skipped
in both bootconfig_cmdline_requested() and setup_boot_config(), so no
bootconfig is applied at all.
Hmm, we need to check all cfgs[i].enabled at first and if no one is
enabled and IS_ENABLED(CONFIG_BOOT_CONFIG_FORCE) then fallback to
enable the first one.
Thanks,
--
Masami Hiramatsu (Google) [off-list ref]