* [PATCH] bootconfig: remove unreachable index checks in xbc_verify_tree()
@ 2026-09-05 14:16 Sang-Heon Jeon
2026-09-08 1:46 ` Masami Hiramatsu
0 siblings, 1 reply; 5+ messages in thread
From: Sang-Heon Jeon @ 2026-09-05 14:16 UTC (permalink / raw)
To: Andrew Morton, Masami Hiramatsu; +Cc: linux-trace-kernel
xbc_verify_tree() checks that every node's next and child are below
xbc_node_num. Both fields store the index of an existing node, which
is below xbc_node_num.
So remove the checks.
No functional change.
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
lib/bootconfig.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index 89c88e359179..d383430637ee 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -1005,7 +1005,7 @@ static int __init xbc_close_brace(char **k, char *n)
static int __init xbc_verify_tree(void)
{
- int i, depth;
+ int depth;
size_t len, wlen;
struct xbc_node *n, *m;
@@ -1022,17 +1022,6 @@ static int __init xbc_verify_tree(void)
return -ENOENT;
}
- for (i = 0; i < xbc_node_num; i++) {
- if (xbc_nodes[i].next >= xbc_node_num) {
- return xbc_parse_error("No closing brace",
- xbc_node_get_data(xbc_nodes + i));
- }
- if (xbc_nodes[i].child >= xbc_node_num) {
- return xbc_parse_error("Broken child node",
- xbc_node_get_data(xbc_nodes + i));
- }
- }
-
/* Key tree limitation check */
n = &xbc_nodes[0];
depth = 1;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] bootconfig: remove unreachable index checks in xbc_verify_tree()
2026-09-05 14:16 [PATCH] bootconfig: remove unreachable index checks in xbc_verify_tree() Sang-Heon Jeon
@ 2026-09-08 1:46 ` Masami Hiramatsu
2026-09-08 15:34 ` Sang-Heon Jeon
0 siblings, 1 reply; 5+ messages in thread
From: Masami Hiramatsu @ 2026-09-08 1:46 UTC (permalink / raw)
To: Sang-Heon Jeon; +Cc: Andrew Morton, linux-trace-kernel
On Sat, 5 Sep 2026 23:16:36 +0900
Sang-Heon Jeon <ekffu200098@gmail.com> wrote:
> xbc_verify_tree() checks that every node's next and child are below
> xbc_node_num. Both fields store the index of an existing node, which
> is below xbc_node_num.
This is a kind of foolpoof/defensive checking. (so I call it verify.)
>
> So remove the checks.
>
> No functional change.
Hmm, OK, I think we should decouple the logic/implementation
verification from runtime verification (e.g. wrong format)
and move the former to tools/bootconfig.
Thank you,
>
> Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
> ---
> lib/bootconfig.c | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/lib/bootconfig.c b/lib/bootconfig.c
> index 89c88e359179..d383430637ee 100644
> --- a/lib/bootconfig.c
> +++ b/lib/bootconfig.c
> @@ -1005,7 +1005,7 @@ static int __init xbc_close_brace(char **k, char *n)
>
> static int __init xbc_verify_tree(void)
> {
> - int i, depth;
> + int depth;
> size_t len, wlen;
> struct xbc_node *n, *m;
>
> @@ -1022,17 +1022,6 @@ static int __init xbc_verify_tree(void)
> return -ENOENT;
> }
>
> - for (i = 0; i < xbc_node_num; i++) {
> - if (xbc_nodes[i].next >= xbc_node_num) {
> - return xbc_parse_error("No closing brace",
> - xbc_node_get_data(xbc_nodes + i));
> - }
> - if (xbc_nodes[i].child >= xbc_node_num) {
> - return xbc_parse_error("Broken child node",
> - xbc_node_get_data(xbc_nodes + i));
> - }
> - }
> -
> /* Key tree limitation check */
> n = &xbc_nodes[0];
> depth = 1;
> --
> 2.43.0
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bootconfig: remove unreachable index checks in xbc_verify_tree()
2026-09-08 1:46 ` Masami Hiramatsu
@ 2026-09-08 15:34 ` Sang-Heon Jeon
2026-09-08 23:24 ` Masami Hiramatsu
0 siblings, 1 reply; 5+ messages in thread
From: Sang-Heon Jeon @ 2026-09-08 15:34 UTC (permalink / raw)
To: Masami Hiramatsu; +Cc: Andrew Morton, linux-trace-kernel
Hi,
On Tue, Sep 8, 2026 at 10:46 AM Masami Hiramatsu <mhiramat@kernel.org> wrote:
>
> On Sat, 5 Sep 2026 23:16:36 +0900
> Sang-Heon Jeon <ekffu200098@gmail.com> wrote:
>
> > xbc_verify_tree() checks that every node's next and child are below
> > xbc_node_num. Both fields store the index of an existing node, which
> > is below xbc_node_num.
>
> This is a kind of foolpoof/defensive checking. (so I call it verify.)
>
> >
> > So remove the checks.
> >
> > No functional change.
>
> Hmm, OK, I think we should decouple the logic/implementation
> verification from runtime verification (e.g. wrong format)
> and move the former to tools/bootconfig.
>
> Thank you,
Thanks for the review, Masami.
To make sure I understand, you mean moving the foolproof check after
xbc_init() in tools/bootconfig?
> >
> > Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
> > ---
> > lib/bootconfig.c | 13 +------------
> > 1 file changed, 1 insertion(+), 12 deletions(-)
> >
> > diff --git a/lib/bootconfig.c b/lib/bootconfig.c
> > index 89c88e359179..d383430637ee 100644
> > --- a/lib/bootconfig.c
> > +++ b/lib/bootconfig.c
> > @@ -1005,7 +1005,7 @@ static int __init xbc_close_brace(char **k, char *n)
> >
> > static int __init xbc_verify_tree(void)
> > {
> > - int i, depth;
> > + int depth;
> > size_t len, wlen;
> > struct xbc_node *n, *m;
> >
> > @@ -1022,17 +1022,6 @@ static int __init xbc_verify_tree(void)
> > return -ENOENT;
> > }
> >
> > - for (i = 0; i < xbc_node_num; i++) {
> > - if (xbc_nodes[i].next >= xbc_node_num) {
> > - return xbc_parse_error("No closing brace",
> > - xbc_node_get_data(xbc_nodes + i));
> > - }
> > - if (xbc_nodes[i].child >= xbc_node_num) {
> > - return xbc_parse_error("Broken child node",
> > - xbc_node_get_data(xbc_nodes + i));
> > - }
> > - }
> > -
> > /* Key tree limitation check */
> > n = &xbc_nodes[0];
> > depth = 1;
> > --
> > 2.43.0
> >
>
>
> --
> Masami Hiramatsu (Google) <mhiramat@kernel.org>
Best regards,
Sang-Heon Jeon
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bootconfig: remove unreachable index checks in xbc_verify_tree()
2026-09-08 15:34 ` Sang-Heon Jeon
@ 2026-09-08 23:24 ` Masami Hiramatsu
2026-09-09 1:27 ` Sang-Heon Jeon
0 siblings, 1 reply; 5+ messages in thread
From: Masami Hiramatsu @ 2026-09-08 23:24 UTC (permalink / raw)
To: Sang-Heon Jeon; +Cc: Andrew Morton, linux-trace-kernel
On Wed, 9 Sep 2026 00:34:35 +0900
Sang-Heon Jeon <ekffu200098@gmail.com> wrote:
> Hi,
>
> On Tue, Sep 8, 2026 at 10:46 AM Masami Hiramatsu <mhiramat@kernel.org> wrote:
> >
> > On Sat, 5 Sep 2026 23:16:36 +0900
> > Sang-Heon Jeon <ekffu200098@gmail.com> wrote:
> >
> > > xbc_verify_tree() checks that every node's next and child are below
> > > xbc_node_num. Both fields store the index of an existing node, which
> > > is below xbc_node_num.
> >
> > This is a kind of foolpoof/defensive checking. (so I call it verify.)
> >
> > >
> > > So remove the checks.
> > >
> > > No functional change.
> >
> > Hmm, OK, I think we should decouple the logic/implementation
> > verification from runtime verification (e.g. wrong format)
> > and move the former to tools/bootconfig.
> >
> > Thank you,
>
> Thanks for the review, Masami.
>
> To make sure I understand, you mean moving the foolproof check after
> xbc_init() in tools/bootconfig?
Instead of just removing this, move this verification into tools/bootconfig.
(we still need verification of user given broken bootconfig.)
Let me handle it.
Thank you,
>
> > >
> > > Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
> > > ---
> > > lib/bootconfig.c | 13 +------------
> > > 1 file changed, 1 insertion(+), 12 deletions(-)
> > >
> > > diff --git a/lib/bootconfig.c b/lib/bootconfig.c
> > > index 89c88e359179..d383430637ee 100644
> > > --- a/lib/bootconfig.c
> > > +++ b/lib/bootconfig.c
> > > @@ -1005,7 +1005,7 @@ static int __init xbc_close_brace(char **k, char *n)
> > >
> > > static int __init xbc_verify_tree(void)
> > > {
> > > - int i, depth;
> > > + int depth;
> > > size_t len, wlen;
> > > struct xbc_node *n, *m;
> > >
> > > @@ -1022,17 +1022,6 @@ static int __init xbc_verify_tree(void)
> > > return -ENOENT;
> > > }
> > >
> > > - for (i = 0; i < xbc_node_num; i++) {
> > > - if (xbc_nodes[i].next >= xbc_node_num) {
> > > - return xbc_parse_error("No closing brace",
> > > - xbc_node_get_data(xbc_nodes + i));
> > > - }
> > > - if (xbc_nodes[i].child >= xbc_node_num) {
> > > - return xbc_parse_error("Broken child node",
> > > - xbc_node_get_data(xbc_nodes + i));
> > > - }
> > > - }
> > > -
> > > /* Key tree limitation check */
> > > n = &xbc_nodes[0];
> > > depth = 1;
> > > --
> > > 2.43.0
> > >
> >
> >
> > --
> > Masami Hiramatsu (Google) <mhiramat@kernel.org>
>
> Best regards,
> Sang-Heon Jeon
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bootconfig: remove unreachable index checks in xbc_verify_tree()
2026-09-08 23:24 ` Masami Hiramatsu
@ 2026-09-09 1:27 ` Sang-Heon Jeon
0 siblings, 0 replies; 5+ messages in thread
From: Sang-Heon Jeon @ 2026-09-09 1:27 UTC (permalink / raw)
To: Masami Hiramatsu; +Cc: Andrew Morton, linux-trace-kernel
On Wed, Sep 9, 2026 at 8:25 AM Masami Hiramatsu <mhiramat@kernel.org> wrote:
>
> On Wed, 9 Sep 2026 00:34:35 +0900
> Sang-Heon Jeon <ekffu200098@gmail.com> wrote:
>
> > Hi,
> >
> > On Tue, Sep 8, 2026 at 10:46 AM Masami Hiramatsu <mhiramat@kernel.org> wrote:
> > >
> > > On Sat, 5 Sep 2026 23:16:36 +0900
> > > Sang-Heon Jeon <ekffu200098@gmail.com> wrote:
> > >
> > > > xbc_verify_tree() checks that every node's next and child are below
> > > > xbc_node_num. Both fields store the index of an existing node, which
> > > > is below xbc_node_num.
> > >
> > > This is a kind of foolpoof/defensive checking. (so I call it verify.)
> > >
> > > >
> > > > So remove the checks.
> > > >
> > > > No functional change.
> > >
> > > Hmm, OK, I think we should decouple the logic/implementation
> > > verification from runtime verification (e.g. wrong format)
> > > and move the former to tools/bootconfig.
> > >
> > > Thank you,
> >
> > Thanks for the review, Masami.
> >
> > To make sure I understand, you mean moving the foolproof check after
> > xbc_init() in tools/bootconfig?
>
> Instead of just removing this, move this verification into tools/bootconfig.
> (we still need verification of user given broken bootconfig.)
> Let me handle it.
Thank you for clarifying. I'm looking forward to it!
> Thank you,
>
> >
> > > >
> > > > Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
> > > > ---
> > > > lib/bootconfig.c | 13 +------------
> > > > 1 file changed, 1 insertion(+), 12 deletions(-)
> > > >
> > > > diff --git a/lib/bootconfig.c b/lib/bootconfig.c
> > > > index 89c88e359179..d383430637ee 100644
> > > > --- a/lib/bootconfig.c
> > > > +++ b/lib/bootconfig.c
> > > > @@ -1005,7 +1005,7 @@ static int __init xbc_close_brace(char **k, char *n)
> > > >
> > > > static int __init xbc_verify_tree(void)
> > > > {
> > > > - int i, depth;
> > > > + int depth;
> > > > size_t len, wlen;
> > > > struct xbc_node *n, *m;
> > > >
> > > > @@ -1022,17 +1022,6 @@ static int __init xbc_verify_tree(void)
> > > > return -ENOENT;
> > > > }
> > > >
> > > > - for (i = 0; i < xbc_node_num; i++) {
> > > > - if (xbc_nodes[i].next >= xbc_node_num) {
> > > > - return xbc_parse_error("No closing brace",
> > > > - xbc_node_get_data(xbc_nodes + i));
> > > > - }
> > > > - if (xbc_nodes[i].child >= xbc_node_num) {
> > > > - return xbc_parse_error("Broken child node",
> > > > - xbc_node_get_data(xbc_nodes + i));
> > > > - }
> > > > - }
> > > > -
> > > > /* Key tree limitation check */
> > > > n = &xbc_nodes[0];
> > > > depth = 1;
> > > > --
> > > > 2.43.0
> > > >
> > >
> > >
> > > --
> > > Masami Hiramatsu (Google) <mhiramat@kernel.org>
> >
> > Best regards,
> > Sang-Heon Jeon
>
>
> --
> Masami Hiramatsu (Google) <mhiramat@kernel.org>
Best regards,
Sang-Heon Jeon
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-09 1:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-05 14:16 [PATCH] bootconfig: remove unreachable index checks in xbc_verify_tree() Sang-Heon Jeon
2026-09-08 1:46 ` Masami Hiramatsu
2026-09-08 15:34 ` Sang-Heon Jeon
2026-09-08 23:24 ` Masami Hiramatsu
2026-09-09 1:27 ` Sang-Heon Jeon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox