* FAILED: patch "[PATCH] bootconfig: Trim unquoted values at end of file" failed to apply to 5.10-stable tree
@ 2026-11-24 15:43 gregkh
2026-11-24 19:07 ` [PATCH 5.10.y] bootconfig: Trim unquoted values at end of file Eduardo Mucelli Rezende Oliveira
0 siblings, 1 reply; 2+ messages in thread
From: gregkh @ 2026-11-24 15:43 UTC (permalink / raw)
To: edumucelli, mhiramat; +Cc: stable
The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 381b391bfaa3f10d52da4740529804b0b6b8160d
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026112402-grit-gauntlet-c172@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 381b391bfaa3f10d52da4740529804b0b6b8160d Mon Sep 17 00:00:00 2001
From: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
Date: Tue, 10 Nov 2026 20:08:46 +0100
Subject: [PATCH] bootconfig: Trim unquoted values at end of file
__xbc_parse_value() trims an unquoted value when it encounters a
delimiter, but leaves trailing whitespace intact when it reaches the end
of the input. Thus "key = value " has a different value depending on
whether the file ends with a newline. The extra whitespace also reaches
the rendered kernel command line.
Trim unquoted values after the scan finishes, including at end of input.
Skip trimming after a closing quote so intentional whitespace in quoted
values remains unchanged. Add checks for scalars, arrays and quoted
values without a final newline.
Link: https://lore.kernel.org/all/31f248f330e716b925add3a0ba76f62826527312.1794337724.git.edumucelli@gmail.com/
Fixes: 76db5a27a827 ("bootconfig: Add Extra Boot Config support")
Cc: stable@vger.kernel.org
Signed-off-by: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index a4aae9a9abca..948c8c10e4b9 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -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 */
diff --git a/tools/bootconfig/test-bootconfig.sh b/tools/bootconfig/test-bootconfig.sh
index d19747e47890..f584f7637e12 100755
--- a/tools/bootconfig/test-bootconfig.sh
+++ b/tools/bootconfig/test-bootconfig.sh
@@ -181,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 {
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH 5.10.y] bootconfig: Trim unquoted values at end of file
2026-11-24 15:43 FAILED: patch "[PATCH] bootconfig: Trim unquoted values at end of file" failed to apply to 5.10-stable tree gregkh
@ 2026-11-24 19:07 ` Eduardo Mucelli Rezende Oliveira
0 siblings, 0 replies; 2+ messages in thread
From: Eduardo Mucelli Rezende Oliveira @ 2026-11-24 19:07 UTC (permalink / raw)
To: stable
commit 381b391bfaa3f10d52da4740529804b0b6b8160d upstream.
__xbc_parse_value() trims an unquoted value when it encounters a
delimiter, but leaves trailing whitespace intact when it reaches the end
of the input. Thus "key = value " has a different value depending on
whether the file ends with a newline. The extra whitespace also reaches
the rendered kernel command line.
Trim unquoted values after the scan finishes, including at end of input.
Skip trimming after a closing quote so intentional whitespace in quoted
values remains unchanged. Add checks for scalars, arrays and quoted
values without a final newline.
The stable test script has a different layout. Place the same three
checks before the sample-file tests. The parser change is unchanged.
Link: https://lore.kernel.org/all/31f248f330e716b925add3a0ba76f62826527312.1794337724.git.edumucelli@gmail.com/
Fixes: 76db5a27a827 ("bootconfig: Add Extra Boot Config support")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
---
Hi Greg,
Thanks for the notice. The parser hunk applies to 5.10.y as-is.
I moved the EOF regression tests to the corresponding spot in the
existing test script. The two unquoted cases fail on the original
build and pass with the fix. The bootconfig suite also passes.
Thanks,
Eduardo
lib/bootconfig.c | 5 +++--
tools/bootconfig/test-bootconfig.sh | 18 ++++++++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index f6bede03c6..58ad45a93b 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -556,16 +556,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 */
diff --git a/tools/bootconfig/test-bootconfig.sh b/tools/bootconfig/test-bootconfig.sh
index e36f178f7d..4dffe2bf8c 100755
--- a/tools/bootconfig/test-bootconfig.sh
+++ b/tools/bootconfig/test-bootconfig.sh
@@ -170,6 +170,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 "=== expected failure cases ==="
for i in samples/bad-* ; do
xfail $BOOTCONF -a $i $INITRD
base-commit: 99112ea818e35b606397c84fbc05e6fadb6ea162
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-24 19:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 15:43 FAILED: patch "[PATCH] bootconfig: Trim unquoted values at end of file" failed to apply to 5.10-stable tree gregkh
2026-11-24 19:07 ` [PATCH 5.10.y] bootconfig: Trim unquoted values at end of file Eduardo Mucelli Rezende Oliveira
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.