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=1796379373; b=n7LvMnKZr3xc0QDxmy7R4BTYvlYKIxIZRBZASLuAcJi2qVRx8Slas9t48Z+afXtmDm8I mQHBfT+M7I9QO6lvCCF1QOHbJ0YdEO5SyuPPN/5YD+nJxGsU98iFEGjS2f1XVTXM/eVhQ ZcqwzcNt6xRQxcZu6EVUWRePi+TvirfQJvH8ufNBG4dgIasGW6KvazBK5SXIPueJuRSEw foW13Na7FdnOevRuPmZtRD9xo+qJQVX77TgVdMv/YWcovgha2dpYJYx606WIun1I8aXYs 5d9pKCvTgrY+exck15OndAIHalNa3OPsGg1lT5Gd6FX4jM3NGZtFOS7ZOqkYEgjkMaA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379373; 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=8bMMfcrpoBvxxsfBqfJTwZrw3/Uot3VOlznUSucGmHk=; b=bPm8dGYwZeYhcUAenoYTqnmMOThXVVoNIw0xY0U/l6QENlCK7uIiB2aYahWUQ7Ko9V8M I+jhCxtaw3gbBa9fQcUpi0wfrcd+kaN19TGKnyT3yq9k1b8OaVa5R0UynBcQ1Tr4oUuE1 XorKURVFpVeAVcY6vhWyGd7xx3KAfE4KGYDAcmTux6THKVzHl0LflkvD0rREheCvJgUCq xjYEkuFGjlwLWFmJbGpvV3kTz/O21CTwamCyWE5FYxyWs6JQ0ivwmIo42b05NagwdgNZG zTdWhtjXE3vT2gFOibQIwE8VAQQQ+k7tBm+cS/GRQpK9nRCS07lu6XCukRF79vXrzMw== 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=NMODAtII; 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 D3232606A32C; Fri, 4 Dec 2026 10:16:13 +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=NMODAtII Received: by smtp.kernel.org (Postfix) with ESMTPSA id E397D1F000C2; Fri, 4 Dec 2026 10:16:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379373; bh=8bMMfcrpoBvxxsfBqfJTwZrw3/Uot3VOlznUSucGmHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NMODAtIItMCmkLNxCTbN1w1ZkGy+M4f7fpe8tJfoLQvuu2DkzHSQYmVROWy/WYSQy EQJOR27smpwX/ciNVSG96KVnwWfd0gyyOj4vHqfCFByU4xkkDCl711neoHUNfe2HQQ xWPiQypwLKK6Mzkywd4u9HxcL9rJ4yxcmY+vg8l0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Masami Hiramatsu (Google)" , Eduardo Mucelli Rezende Oliveira , Sasha Levin Subject: [PATCH 6.18 033/703] tools/bootconfig: Close only opened braces in compact output Date: Fri, 4 Dec 2026 18:58:52 +0900 Message-ID: <20261204100628.479799217@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eduardo Mucelli Rezende Oliveira commit 26fa92f351d4993428268afebf6c60c987477af5 upstream. A key may have both a value and subkeys. When it has only one subkey, xbc_show_compact_tree() can print that subkey using dotted notation without opening a brace. During backtracking, however, it treats the value node followed by a subkey as evidence that a brace was opened. For example, a.b=v, a.b.c=w and a.z=q are printed with the brace for a closed before z. Reading that output back changes a.z into the root key z, silently changing the configuration. Check the key children when deciding whether to close a brace. Skip the value child, and account for a sole subkey that itself has both a value and subkeys, since that combination is not compacted. This follows the conditions used to open braces without keeping a depth-indexed array. Extend the mixed-value/subkey sample to cover the lost sibling. The stable test script only checks whether the good samples can be attached. Add the compact-output comparison for the extended mixed-value/subkey sample and add its expected output file. Link: https://lore.kernel.org/all/6ad67e4cda05238cd173c99e820a85de2c13f5fc.1794337724.git.edumucelli@gmail.com/ Fixes: e5efaeb8a8f5 ("bootconfig: Support mixing a value and subkeys under a key") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu (Google) Signed-off-by: Eduardo Mucelli Rezende Oliveira Signed-off-by: Sasha Levin --- tools/bootconfig/main.c | 29 ++++++++++++++----- .../samples/exp-good-mixed-kv1.bconf | 7 +++++ tools/bootconfig/samples/good-mixed-kv1.bconf | 5 ++++ tools/bootconfig/test-bootconfig.sh | 6 ++++ 4 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 tools/bootconfig/samples/exp-good-mixed-kv1.bconf diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c index 6f5d60045f90b..43f0a7fa87c9b 100644 --- a/tools/bootconfig/main.c +++ b/tools/bootconfig/main.c @@ -39,6 +39,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; @@ -99,14 +116,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); } diff --git a/tools/bootconfig/samples/exp-good-mixed-kv1.bconf b/tools/bootconfig/samples/exp-good-mixed-kv1.bconf new file mode 100644 index 0000000000000..0b8b2f59da31e --- /dev/null +++ b/tools/bootconfig/samples/exp-good-mixed-kv1.bconf @@ -0,0 +1,7 @@ +key = "value"; +key.subkey = "another-value"; +a { + b = "v"; + b.c = "w"; + z = "q"; +} diff --git a/tools/bootconfig/samples/good-mixed-kv1.bconf b/tools/bootconfig/samples/good-mixed-kv1.bconf index 1761547dd05ca..35442ee62b751 100644 --- a/tools/bootconfig/samples/good-mixed-kv1.bconf +++ b/tools/bootconfig/samples/good-mixed-kv1.bconf @@ -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 diff --git a/tools/bootconfig/test-bootconfig.sh b/tools/bootconfig/test-bootconfig.sh index d6211efe6dbee..615f5f72ff1a5 100755 --- a/tools/bootconfig/test-bootconfig.sh +++ b/tools/bootconfig/test-bootconfig.sh @@ -200,6 +200,12 @@ for i in samples/good-* ; do done +echo "Compact output keeps siblings under their parent" +xpass $BOOTCONF -a samples/good-mixed-kv1.bconf $INITRD +$BOOTCONF $INITRD > $OUTFILE +xpass cmp samples/exp-good-mixed-kv1.bconf $OUTFILE + + echo echo "=== Summary ===" echo "# of Passed: $(expr $NO - $NG - 1)" -- 2.53.0