public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bootconfig: Fix to terminate value search if it hits a newline
@ 2026-01-30  4:41 Masami Hiramatsu (Google)
  2026-01-30 14:53 ` Steven Rostedt
  0 siblings, 1 reply; 5+ messages in thread
From: Masami Hiramatsu (Google) @ 2026-01-30  4:41 UTC (permalink / raw)
  To: Steven Rostedt, linux-trace-kernel; +Cc: Julius Werner, Masami Hiramatsu, LKML

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Fix bootconfig to terminate the value search if it hits a newline
even if it is empty.

When we pass a bootconfig with an empty value terminated by the
newline, like below::

  foo =
  bar = value

Current bootconfig interprets it as a single entry::

  foo = "bar = value";

However, the Documentation/admin-guide/bootconfig.rst said that

  The value has to be terminated by semi-colon (``;``) or newline (``\n``).

Thus, it should be interpreted as::

  foo = "";
  bar = "value";

Note that if the line has a comment, it still keep searching the
value to the next line::

  foo = # comment
  value

This is interpreted as `foo = "value"`.
This also updates the test script so that it can check the above cases.

Fixes: 76db5a27a827 ("bootconfig: Add Extra Boot Config support")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 tools/bootconfig/test-bootconfig.sh |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index 81f29c29f47b..94b55ec32444 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -563,7 +563,7 @@ static int __init __xbc_parse_value(char **__v, char **__n)
 	char *p, *v = *__v;
 	int c, quotes = 0;
 
-	v = skip_spaces(v);
+	v = skip_spaces_until_newline(v);
 	while (*v == '#') {
 		v = skip_comment(v);
 		v = skip_spaces(v);
diff --git a/tools/bootconfig/test-bootconfig.sh b/tools/bootconfig/test-bootconfig.sh
index 7594659af1e1..0873883182b0 100755
--- a/tools/bootconfig/test-bootconfig.sh
+++ b/tools/bootconfig/test-bootconfig.sh
@@ -171,6 +171,24 @@ $BOOTCONF $INITRD > $OUTFILE
 xfail grep -q 'val[[:space:]]' $OUTFILE
 xpass grep -q 'val2[[:space:]]' $OUTFILE
 
+echo "Empty value with ="
+cat > $TEMPCONF << EOF
+foo =
+bar
+EOF
+$BOOTCONF $TEMPCONF > $OUTFILE
+xfail grep 'foo[[:space:]]=[[:space:]]"bar"' $OUTFILE
+xpass grep 'foo[[:space:]]=[[:space:]]"";' $OUTFILE
+
+echo "Continue value after comment"
+cat > $TEMPCONF << EOF
+foo = # comment
+bar
+EOF
+$BOOTCONF $TEMPCONF > $OUTFILE
+xpass grep 'foo[[:space:]]=[[:space:]]"bar"' $OUTFILE
+xfail grep 'foo[[:space:]]=[[:space:]]"";' $OUTFILE
+
 echo "=== expected failure cases ==="
 for i in samples/bad-* ; do
   xfail $BOOTCONF -a $i $INITRD


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-02-02 23:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-30  4:41 [PATCH] bootconfig: Fix to terminate value search if it hits a newline Masami Hiramatsu (Google)
2026-01-30 14:53 ` Steven Rostedt
2026-01-30 23:26   ` Julius Werner
2026-01-31  2:19     ` Masami Hiramatsu
2026-02-02 23:05       ` Julius Werner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox