From nobody Tue Apr 7 06:19:21 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 205992F1FC7 for ; Sun, 15 Mar 2026 10:29:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773570568; cv=none; b=CstfbyRlgLwDRrD5PsMNFK3h/i0ZOQoXgFg/psYNKZ/f3HPaMlXcST8JqgoBbS6yOrLudpTdNluno+oE1r0tEglMDSOt+7fkcukrdirEu6QoSOcg/S/kTIF/o1SSSc8wO7jungodgHIC9uZo1apgK3dTb7KyEkYKdVRbG+gMqvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773570568; c=relaxed/simple; bh=DsaJFYEpi3gQhWIbxpJ4yFtugnOfF+7D0Fnh53qxBm0=; h=Date:From:To:Cc:Subject:Message-Id:Mime-Version:Content-Type; b=QYsMXi539zPd+G3bR2rTeQ/yemsqH941pWetUug5ZZv+5iRNvz+4JTO95gjsM4cvtRsztAW/BWPbaGBtTGRewwU4iYTkmVsRbX1rBP1NlWw+4JxK3ppgc/X2OIgqDSz6zy/HoO7krpD2k1NHzUOhtz8BFwQWk9lGG/IytU+Pg24= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HanzOpuh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HanzOpuh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E49ABC4CEF7; Sun, 15 Mar 2026 10:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773570567; bh=DsaJFYEpi3gQhWIbxpJ4yFtugnOfF+7D0Fnh53qxBm0=; h=Date:From:To:Cc:Subject:From; b=HanzOpuhp3Ob+B7zEbLC99bY1XMAGAwtIZ73Z98ezw8Km3sVvV3arw9slbhl621H3 cwZ8IH6jECPqOoQSs4iQ86vLuSNm0rwHx5NPuSfrQ6zIvUZP3d7G87JvfvdVfn33IY lXjsMrYtTLuBEWpBre7wIl/FAdejdoZLsmm2/k5coXFMfHncWUUE/TBrYeO43fX6+K 0pk3jsS13cKW7MyFE8qihFaVFJtXnBzQpCJlIO5Rk4iW55i7JGHv3q2CCKzS/ngMjM QoI42zJ0kSfoDEJpHhfRlpWJ/BhwKShf3hC/4Px8aV2EX5hH5aCfchESDSD26lswY8 2JvZ7T/Ny0MfQ== Date: Sun, 15 Mar 2026 19:29:23 +0900 From: Masami Hiramatsu (Google) To: Linus Torvalds Cc: Josh Law , Masami Hiramatsu (Google) , Steven Rostedt , linux-kernel@vger.kernel.org Subject: [GIT PULL] bootconfig: Fixes for v7.0-rc3 Message-Id: <20260315192923.8f68f4a53891714313be6de8@kernel.org> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Hi Linus, Bootconfig fixes for v7.0-rc3 - lib/bootconfig: fix off-by-one in xbc_verify_tree() unclosed brace error; This fixes a wrong error place in unclosed brace error message. - lib/bootconfig: check bounds before writing in __xbc_open_brace(); This fixes to check the array index before setting array, so that the bootconfig can support 16th-depth nested brace correctly. - lib/bootconfig: fix snprintf truncation check in xbc_node_compose_key_after(); This fixes to handle the return value of snprintf() correctly in case of the return value =3D=3D size. - bootconfig: Add bootconfig tests about braces Add test cases for checking error position about unclosed brace and ensuring supporting 16th depth nested braces correctly. Please pull the latest bootconfig-fixes-v7.0-rc3 tree, which can be found a= t: git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git bootconfig-fixes-v7.0-rc3 Tag SHA1: cf0695efdf302e25697c8ca4f93b93686cf086fc Head SHA1: e2715ea5fb352cd43fce437b91aa0fd50aaaf384 Josh Law (3): lib/bootconfig: fix off-by-one in xbc_verify_tree() unclosed brace er= ror lib/bootconfig: check bounds before writing in __xbc_open_brace() lib/bootconfig: fix snprintf truncation check in xbc_node_compose_key= _after() Masami Hiramatsu (Google) (1): bootconfig: Add bootconfig tests about braces ---- lib/bootconfig.c | 6 +++--- tools/bootconfig/samples/bad-non-closed-brace.bconf | 4 ++++ tools/bootconfig/samples/bad-over-max-brace.bconf | 19 ++++++++++++++++= +++ tools/bootconfig/samples/exp-good-nested-brace.bconf | 1 + tools/bootconfig/samples/good-nested-brace.bconf | 18 ++++++++++++++++= ++ tools/bootconfig/test-bootconfig.sh | 9 +++++++++ 6 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 tools/bootconfig/samples/bad-non-closed-brace.bconf create mode 100644 tools/bootconfig/samples/bad-over-max-brace.bconf create mode 100644 tools/bootconfig/samples/exp-good-nested-brace.bconf create mode 100644 tools/bootconfig/samples/good-nested-brace.bconf --------------------------- diff --git a/lib/bootconfig.c b/lib/bootconfig.c index 449369a60846..2da049216fe0 100644 --- a/lib/bootconfig.c +++ b/lib/bootconfig.c @@ -316,7 +316,7 @@ int __init xbc_node_compose_key_after(struct xbc_node *= root, depth ? "." : ""); if (ret < 0) return ret; - if (ret > size) { + if (ret >=3D size) { size =3D 0; } else { size -=3D ret; @@ -532,9 +532,9 @@ static char *skip_spaces_until_newline(char *p) static int __init __xbc_open_brace(char *p) { /* Push the last key as open brace */ - open_brace[brace_index++] =3D xbc_node_index(last_parent); if (brace_index >=3D XBC_DEPTH_MAX) return xbc_parse_error("Exceed max depth of braces", p); + open_brace[brace_index++] =3D xbc_node_index(last_parent); =20 return 0; } @@ -802,7 +802,7 @@ static int __init xbc_verify_tree(void) =20 /* Brace closing */ if (brace_index) { - n =3D &xbc_nodes[open_brace[brace_index]]; + n =3D &xbc_nodes[open_brace[brace_index - 1]]; return xbc_parse_error("Brace is not closed", xbc_node_get_data(n)); } diff --git a/tools/bootconfig/samples/bad-non-closed-brace.bconf b/tools/bo= otconfig/samples/bad-non-closed-brace.bconf new file mode 100644 index 000000000000..6ed9f3363dde --- /dev/null +++ b/tools/bootconfig/samples/bad-non-closed-brace.bconf @@ -0,0 +1,4 @@ +foo { + bar { + buz + } diff --git a/tools/bootconfig/samples/bad-over-max-brace.bconf b/tools/boot= config/samples/bad-over-max-brace.bconf new file mode 100644 index 000000000000..74b5dc9e21dc --- /dev/null +++ b/tools/bootconfig/samples/bad-over-max-brace.bconf @@ -0,0 +1,19 @@ +key1 { +key2 { +key3 { +key4 { +key5 { +key6 { +key7 { +key8 { +key9 { +key10 { +key11 { +key12 { +key13 { +key14 { +key15 { +key16 { +key17 { +}}}}}}}}}}}}}}}}} + diff --git a/tools/bootconfig/samples/exp-good-nested-brace.bconf b/tools/b= ootconfig/samples/exp-good-nested-brace.bconf new file mode 100644 index 000000000000..19e0f51b4553 --- /dev/null +++ b/tools/bootconfig/samples/exp-good-nested-brace.bconf @@ -0,0 +1 @@ +key1.key2.key3.key4.key5.key6.key7.key8.key9.key10.key11.key12.key13.key14= .key15.key16; diff --git a/tools/bootconfig/samples/good-nested-brace.bconf b/tools/bootc= onfig/samples/good-nested-brace.bconf new file mode 100644 index 000000000000..980d094f296e --- /dev/null +++ b/tools/bootconfig/samples/good-nested-brace.bconf @@ -0,0 +1,18 @@ +key1 { +key2 { +key3 { +key4 { +key5 { +key6 { +key7 { +key8 { +key9 { +key10 { +key11 { +key12 { +key13 { +key14 { +key15 { +key16 { +}}}}}}}}}}}}}}}} + diff --git a/tools/bootconfig/test-bootconfig.sh b/tools/bootconfig/test-bo= otconfig.sh index be9bd18b1d56..fc69f815ce4a 100755 --- a/tools/bootconfig/test-bootconfig.sh +++ b/tools/bootconfig/test-bootconfig.sh @@ -171,6 +171,15 @@ $BOOTCONF $INITRD > $OUTFILE xfail grep -q 'val[[:space:]]' $OUTFILE xpass grep -q 'val2[[:space:]]' $OUTFILE =20 +echo "Showing correct line:column of no closing brace" +cat > $TEMPCONF << EOF +foo { +bar { +} +EOF +$BOOTCONF -a $TEMPCONF $INITRD 2> $OUTFILE +xpass grep -q "1:1" $OUTFILE + echo "=3D=3D=3D expected failure cases =3D=3D=3D" for i in samples/bad-* ; do xfail $BOOTCONF -a $i $INITRD --=20 Masami Hiramatsu (Google)