Skip to contentSkip to conversation

bootconfig: Fixes for v7.4-rc3

GIT PULL Merged Masami Hiramatsu (Google) 3 participants 3 messages Nov 14 – Nov 15

Subsystems (2)
lore
Share & tools
lore

Masami Hiramatsu (Google)

author maintainer
#0 lore raw

Linus,

Bootconfig fixes for v7.4-rc3:

- bootconfig: Allow keys with the maximum supported depth Check the array capacity before storing the next key component in xbc_node_compose_key_after() so keys at XBC_DEPTH_MAX (16) are composed instead of failing with -ERANGE when listing keys or creating /proc/bootconfig.

- bootconfig: Trim unquoted values at end of file
Trim trailing whitespace from unquoted values in __xbc_parse_value() after scanning finishes so values at end of input without a trailing newline do not retain extra whitespace.

- tools/bootconfig: Close only opened braces in compact output Check key children while skipping value nodes when backtracking in xbc_show_compact_tree() so a brace is not closed when a single subkey under a valued key was printed in dotted notation.

- tools/bootconfig: Test listing keys at the maximum depth Add regression tests verifying that a 16-component key can be attached and listed in full while a 17-component key is rejected.

Please pull the latest bootconfig-fixes-v7.4-rc3 tree, which can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
bootconfig-fixes-v7.4-rc3

Tag SHA1: ef934e66dc2ea3b19bcad8722df6beaff4f5e34c Head SHA1: 381b391bfaa3f10d52da4740529804b0b6b8160d

Eduardo Mucelli Rezende Oliveira (2):
tools/bootconfig: Close only opened braces in compact output
bootconfig: Trim unquoted values at end of file

Zhiqi Zhang (2):
bootconfig: Allow keys with the maximum supported depth tools/bootconfig: Test listing keys at the maximum depth

----

 lib/bootconfig.c                                  |  7 +++---
 tools/bootconfig/main.c                           | 29 +++++++++++++++++------
 tools/bootconfig/samples/exp-good-mixed-kv1.bconf |  5 ++++
 tools/bootconfig/samples/good-mixed-kv1.bconf     |  5 ++++
 tools/bootconfig/test-bootconfig.sh               | 28 ++++++++++++++++++++++
 5 files changed, 64 insertions(+), 10 deletions(-)

---------------------------

lib/bootconfig.c +4 -3
index 819685d6c68d..948c8c10e4b9 100644
@@ -428,9 +428,9 @@ int __init xbc_node_compose_key_after(struct xbc_node *root,
 		node = xbc_node_get_parent(node);
 
 	while (node && node != root) {
-		keys[depth++] = xbc_node_index(node);
 		if (depth == XBC_DEPTH_MAX)
 			return -ERANGE;
+		keys[depth++] = xbc_node_index(node);
 		node = xbc_node_get_parent(node);
 	}
 	if (!node && root)
@@ -793,16 +793,17 @@ static int __init __xbc_parse_value(char **__v, char **__n)
 				return xbc_parse_error("No value delimiter", p);
 			if (*p)
 				p++;
-			break;
+			goto skip_trim;
 		}
 		if (strchr(",;\n#}", c)) {
 			*p++ = '\0';
-			v = strim(v);
 			break;
 		}
 	}
 	if (quotes)
 		return xbc_parse_error("No closing quotes", p);
+	v = strim(v);
+skip_trim:
 	if (c == '#') {
 		p = skip_comment(p);
 		c = '\n';	/* A comment must be treated as a newline */
tools/bootconfig/main.c +22 -7
index 6f476e3c06b8..d3f840c5adce 100644
@@ -68,6 +68,23 @@ static int xbc_show_value(struct xbc_node *node, bool semicolon)
 	return i;
 }
 
+/* Match the conditions under which the compact formatter opens braces. */
+static bool xbc_node_needs_braces(struct xbc_node *node)
+{
+	struct xbc_node *child = xbc_node_get_child(node);
+
+	if (child && xbc_node_is_value(child))
+		child = xbc_node_get_next(child);
+	if (!child)
+		return false;
+	if (child->next)
+		return true;
+
+	/* A single subkey with both a value and subkeys is not compacted. */
+	child = xbc_node_get_child(child);
+	return child && xbc_node_is_value(child) && child->next;
+}
+
 static void xbc_show_compact_tree(void)
 {
 	struct xbc_node *node, *cnode = NULL, *vnode;
@@ -128,14 +145,12 @@ static void xbc_show_compact_tree(void)
 			node = xbc_node_get_parent(node);
 			if (!node)
 				return;
-			if (!xbc_node_get_child(node)->next)
+			if (!depth || !xbc_node_needs_braces(node))
 				continue;
-			if (depth) {
-				depth--;
-				for (i = 0; i < depth; i++)
-					printf("\t");
-				printf("}\n");
-			}
+			depth--;
+			for (i = 0; i < depth; i++)
+				printf("\t");
+			printf("}\n");
 		}
 		node = xbc_node_get_next(node);
 	}
tools/bootconfig/samples/exp-good-mixed-kv1.bconf +5 -0
index 8346287d9251..0b8b2f59da31 100644
@@ -1,2 +1,7 @@
 key = "value";
 key.subkey = "another-value";
+a {
+	b = "v";
+	b.c = "w";
+	z = "q";
+}
tools/bootconfig/samples/good-mixed-kv1.bconf +5 -0
index 1761547dd05c..35442ee62b75 100644
@@ -1,3 +1,8 @@
 # value -> subkey pattern
 key = value
 key.subkey = another-value
+
+# A valued parent with one subkey must not close its enclosing brace.
+a.b = v
+a.b.c = w
+a.z = q
tools/bootconfig/test-bootconfig.sh +28 -0
index 530ce7e28d63..f584f7637e12 100755
@@ -100,6 +100,16 @@ xpass $BOOTCONF -a $TEMPCONF $INITRD
 printf "badnode\n" >> $TEMPCONF
 xfail $BOOTCONF -a $TEMPCONF $INITRD
 
+echo "Max key depth check"
+
+printf 'a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p = "value"\n' > $TEMPCONF
+xpass $BOOTCONF -a $TEMPCONF $INITRD
+$BOOTCONF -l $INITRD > $OUTFILE
+xpass cmp $TEMPCONF $OUTFILE
+
+printf 'a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q = "value"\n' > $TEMPCONF
+xfail $BOOTCONF -a $TEMPCONF $INITRD
+
 echo "Max filesize check"
 
 # Max size is 32767 (including terminal byte)
@@ -171,6 +181,24 @@ $BOOTCONF $INITRD > $OUTFILE
 xfail grep -q 'val[[:space:]]' $OUTFILE
 xpass grep -q 'val2[[:space:]]' $OUTFILE
 
+echo "Remove unquoted trailing whitespace at end of file"
+printf 'foo = val \t' > $TEMPCONF
+$BOOTCONF -l $TEMPCONF > $OUTFILE
+printf 'foo = "val"\n' > $TEMPCONF
+xpass cmp $TEMPCONF $OUTFILE
+
+echo "Remove trailing whitespace from the last array value at end of file"
+printf 'foo = first, last \t' > $TEMPCONF
+$BOOTCONF -l $TEMPCONF > $OUTFILE
+printf 'foo = "first", "last"\n' > $TEMPCONF
+xpass cmp $TEMPCONF $OUTFILE
+
+echo "Keep quoted trailing whitespace at end of file"
+printf 'foo = "val "' > $TEMPCONF
+$BOOTCONF -l $TEMPCONF > $OUTFILE
+printf 'foo = "val "\n' > $TEMPCONF
+xpass cmp $TEMPCONF $OUTFILE
+
 echo "Showing correct line:column of no closing brace"
 cat > $TEMPCONF << EOF
 foo {
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
merge bot Merged
#1 lore raw
The pull request you sent on Sat, 14 Nov 2026 20:58:36 +0900:

The pull request you sent on Sat, 14 Nov 2026 20:58:36 +0900:

Quoted 1 line

git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git bootconfig-fixes-v7.4-rc3

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/442fbdb90e120c39bc0b27ffdcc6d7733472ddb9

Thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html
#2 lore raw

Hi Masami,

Thank you for taking it into consideration.

Have a great day,

Quoted 13 lines · On Sun, Nov 15, 2026 at 7:36 PM <[email protected]> wrote:

The pull request you sent on Sat, 14 Nov 2026 20:58:36 +0900:

Quoted 1 line

git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git bootconfig-fixes-v7.4-rc3

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/442fbdb90e120c39bc0b27ffdcc6d7733472ddb9

Thank you!

--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

Signature · 1 line
Eduardo Mucelli R. Oliveira -- http://eduar.do