From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388524; b=deKmf1zBD569M/XQqD8aNrh+zuRQc56NCogSqUI5ke2TT/udAutiQd7fXQ1V7M4mYfWA xkqSMyNqJCEP07fHWeFR0YEFfqoy3aQ+M+V+tCe6GY3JvnNcp+iEjZFFSdhOVIHj/4Rg4 dWmLfHL742D6fgO9K0xW1iGNzhI9EblJkB5hIfMFphdqnYoUT5iu9oDVyLyEUV3WYrXkc iCYhBrv0FeCYV2xppavKwzsdc9nwaYlC3zTuQ7LXNx3EhnISWMqF3UUmVSwr0SgJyfn5h mFTArenTpvacVFrricDQDro2wUGONc/NxK+nTQ9giKztJVaJsxEoDOvpwZC7YSGRjCA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388524; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=ZqcLEdleF5zzG8XNBCVWYC8sujf2mcs/MxHASL/Xs8c=; b=SDsO8Cyn5xjZwxJEzB8CrDLVcQzvX9Mw9jLona0G2SmDk8D3kkCsxSUIODyU9A3ecrzN XFioe66+3W3JD8LW954T6+qRHTVndhPFG0QdrLUEkIWbpdzUarx6RdUkzRA3iBIZwwS9S i3ON/yxFKVcNUG6LkXUdtjEdHY6mHuFQ/UlTSFqBLtNO0aPJ6XPbrZhkjF85WXF+VrKBv KGoTbtx7mmXOjLOQl0PFSL6FRYQo5k/sP9ya4S1gnWYG0UDy8UqY7dSoEJ/b3VHXwdk9X dY33pRiK5DTg+vHqA445FyxX/Yzzbf+optLFeilJoKB9uLZFuLV2VBXou1t/TBRNDLQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ypOfwk5g; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06CCB606A322; Fri, 4 Dec 2026 12:48:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ypOfwk5g Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70E081F000C2; Fri, 4 Dec 2026 12:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388523; bh=ZqcLEdleF5zzG8XNBCVWYC8sujf2mcs/MxHASL/Xs8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ypOfwk5gDqFl+Il/hV309h3UdDKcl6t3aKS7TphSvRZkplI3mzuf6fMg5pGIY4UHf 0Y2o664iOGg0bbnc76NNxOC56jsgDHBXHGle2hO4M4lbF//8gN4PlDUvhxMYZpI44a lobtWYm+oD6ZWCouKZTi2uZJQEfpTLVWCgj5nGYI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eduardo Mucelli Rezende Oliveira , "Masami Hiramatsu (Google)" Subject: [PATCH 6.1 0650/1059] bootconfig: Trim unquoted values at end of file Date: Fri, 4 Dec 2026 19:03:01 +0900 Message-ID: <20261204100700.898713900@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eduardo Mucelli Rezende Oliveira 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. 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 Signed-off-by: Masami Hiramatsu (Google) Signed-off-by: Eduardo Mucelli Rezende Oliveira Signed-off-by: Greg Kroah-Hartman --- lib/bootconfig.c | 5 +++-- tools/bootconfig/test-bootconfig.sh | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) --- a/lib/bootconfig.c +++ b/lib/bootconfig.c @@ -654,16 +654,17 @@ static int __init __xbc_parse_value(char 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 */ --- 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