Thread (5 messages) 5 messages, 2 authors, 2026-09-09

Re: [PATCH] bootconfig: remove unreachable index checks in xbc_verify_tree()

flat view

From: Sang-Heon Jeon <hidden>
Date: 2026-09-08 15:34:49

Hi,

On Tue, Sep 8, 2026 at 10:46 AM Masami Hiramatsu [off-list ref] wrote:
On Sat,  5 Sep 2026 23:16:36 +0900
Sang-Heon Jeon [off-list ref] wrote:
quoted
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.)
quoted
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?
quoted
Signed-off-by: Sang-Heon Jeon <redacted>
---
 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) [off-list ref]
Best regards,
Sang-Heon Jeon
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help