]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
lib/bootconfig: validate child node index in xbc_verify_tree()
authorJosh Law <objecting@objecting.org>
Wed, 18 Mar 2026 15:59:14 +0000 (15:59 +0000)
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>
Wed, 18 Mar 2026 23:44:15 +0000 (08:44 +0900)
xbc_verify_tree() validates that each node's next index is within
bounds, but does not check the child index.  Add the same bounds
check for the child field.

Without this check, a corrupt bootconfig that passes next-index
validation could still trigger an out-of-bounds memory access via an
invalid child index when xbc_node_get_child() is called during tree
traversal at boot time.

Link: https://lore.kernel.org/all/20260318155919.78168-9-objecting@objecting.org/
Signed-off-by: Josh Law <objecting@objecting.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
lib/bootconfig.c

index 0663b74ad131103d18e3c267fee737a83c273e1a..8c50e942d7479cff40fe9618dfcc3d5150afb5ba 100644 (file)
@@ -824,6 +824,10 @@ static int __init xbc_verify_tree(void)
                        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 */