bootconfig: remove unreachable index checks in xbc_verify_tree()
Subsystems (3)
PATCH 1/1 bootconfig: remove unreachable index checks in xbc_verify_tree()
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.
--- lib/bootconfig.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
lib/bootconfig.c +1 -12
@@ -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 ;
Signature · 1 line
2.43.0
Masami Hiramatsu (Google)
maintainerQuoted 3 lines · On Sat, 5 Sep 2026 23:16:36 +0900 Sang-Heon Jeon <[email protected]> wrote:
xbc_verify_tree()checks that every node's next and child are belowxbc_node_num. Both fields store the index of an existing node, which is belowxbc_node_num.
This is a kind of foolpoof/defensive checking. (so I call it verify.)
Quoted 4 lines
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,
Quoted 40 lines
Signed-off-by Sang-Heon Jeon <[email protected]>--- lib/bootconfig.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)lib/bootconfig.c +1
-12@@ -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 ;Signature · 1 line
2.43.0
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Hi,
Quoted 13 lines · Masami Hiramatsu
Quoted 3 lines · On Sat, 5 Sep 2026 23:16:36 +0900 Sang-Heon Jeon <[email protected]> wrote:
xbc_verify_tree()checks that every node's next and child are belowxbc_node_num. Both fields store the index of an existing node, which is belowxbc_node_num.This is a kind of foolpoof/defensive checking. (so I call it verify.)
Quoted 3 lines
So remove the checks.
Quoted 7 lines
Quoted 1 line
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?
Quoted 36 lines
Quoted 36 lines
Signed-off-by Sang-Heon Jeon <[email protected]>--- lib/bootconfig.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)lib/bootconfig.c +1
-12@@ -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 ];
Quoted 8 lines
Quoted 4 lines
lib/bootconfig.c +0
-1depth =1 ; --2.43.0
--
Masami Hiramatsu (Google) <[email protected]>
Best regards,
Sang-Heon Jeon
Masami Hiramatsu (Google)
maintainerQuoted 22 lines · On Wed, 9 Sep 2026 00:34:35 +0900 Sang-Heon Jeon <[email protected]> wrote:
Hi,
Quoted 19 lines · Masami Hiramatsu
Quoted 3 lines · On Sat, 5 Sep 2026 23:16:36 +0900 Sang-Heon Jeon <[email protected]> wrote:
xbc_verify_tree()checks that every node's next and child are belowxbc_node_num. Both fields store the index of an existing node, which is belowxbc_node_num.This is a kind of foolpoof/defensive checking. (so I call it verify.)
Quoted 4 lines
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.
Quoted 6 lines
Quoted 1 line
Thank you,
Thanks for the review, Masami.
To make sure I understand, you mean moving the foolproof check after
xbc_init()intools/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,
Quoted 48 lines
Quoted 37 lines
Quoted 37 lines
Signed-off-by Sang-Heon Jeon <[email protected]>--- lib/bootconfig.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)lib/bootconfig.c +1
-12@@ -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 ];Quoted 8 lines
Quoted 4 lines
lib/bootconfig.c +0
-1depth =1 ; --2.43.0
--
Masami Hiramatsu (Google) <[email protected]>Best regards,
Sang-Heon Jeon
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
Quoted 28 lines · Masami Hiramatsu
Quoted 24 lines · On Wed, 9 Sep 2026 00:34:35 +0900 Sang-Heon Jeon <[email protected]> wrote:
Hi,
Quoted 20 lines · Masami Hiramatsu
Quoted 3 lines · On Sat, 5 Sep 2026 23:16:36 +0900 Sang-Heon Jeon <[email protected]> wrote:
xbc_verify_tree()checks that every node's next and child are belowxbc_node_num. Both fields store the index of an existing node, which is belowxbc_node_num.This is a kind of foolpoof/defensive checking. (so I call it verify.)
Quoted 4 lines
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,
Quoted 8 lines
Quoted 4 lines
Thanks for the review, Masami.
To make sure I understand, you mean moving the foolproof check after
xbc_init()intools/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!
Quoted 48 lines
Thank you,
Quoted 46 lines
Quoted 45 lines
Quoted 39 lines
Signed-off-by Sang-Heon Jeon <[email protected]>--- lib/bootconfig.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)lib/bootconfig.c +1
-13@@ -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 ; --Quoted 2 lines
2.43.0
--
Masami Hiramatsu (Google) <[email protected]>
Quoted 6 lines
Quoted 2 lines
Best regards,
Sang-Heon Jeon--
Masami Hiramatsu (Google) <[email protected]>
Best regards,
Sang-Heon Jeon