summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorLeizhen Zhang <lzsx618@gmail.com>2026-10-08 11:45:28 -0500
committerNicolas Schier <nsc@kernel.org>2026-11-05 07:32:59 +0100
commitfa88726397ab4bbba2d3c466f0941510a11eb9d0 (patch)
tree9298aafd4e4b57f23461bf5739c9798a16d072de /scripts
parent3910d22df6845ed40aa01f4869655e0442ca2e5b (diff)
downloadlinux-next-fa88726397ab4bbba2d3c466f0941510a11eb9d0.tar.gz
linux-next-fa88726397ab4bbba2d3c466f0941510a11eb9d0.zip
kconfig: fix dangling check_top after an unexpected recursive dependency
If the last symbol of a recursive dependency is a choice value, sym_check_print_recursive() pushes the on-stack cv_stack onto the dependency stack. If the choice is then not found on the stack, the function prints "unexpected recursive dependency error" and returns without removing cv_stack again. check_top is left pointing into the stack frame of the returned function, and the next dep_stack_remove() dereferences it: AddressSanitizer: stack-use-after-return ... in dep_stack_remove This can be triggered by an (invalid) Kconfig file in which a symbol is a choice value of two choices and the second choice depends on it: choice prompt "c1" config A bool "a" endchoice choice prompt "c2" depends on A config A bool "a" endchoice Jump to the existing cleanup at the end of the function instead of returning directly. Found by fuzzing Kconfig input with ASan/UBSan. Fixes: d595cea62403 ("kconfig: print more info when we see a recursive dependency") Assisted-by: Claude:claude-opus-5-5 ASan UBSan libFuzzer Signed-off-by: Leizhen Zhang <lzsx618@gmail.com> Reviewed-by: Julian Braha <julianbraha@gmail.com> Reviewed-by: Nathan Chancellor <nathan@kernel.org> Link: https://patch.msgid.link/20261008164528.3685545-1-lzsx618@gmail.com Signed-off-by: Nicolas Schier <nsc@kernel.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/kconfig/symbol.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index f6fadb077381..27138252c667 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -1186,7 +1186,7 @@ static void sym_check_print_recursive(struct symbol *last_sym)
break;
if (!stack) {
fprintf(stderr, "unexpected recursive dependency error\n");
- return;
+ goto out;
}
for (; stack; stack = stack->next) {
@@ -1231,6 +1231,7 @@ static void sym_check_print_recursive(struct symbol *last_sym)
"subsection \"Kconfig recursive dependency limitations\"\n"
"\n");
+out:
if (check_top == &cv_stack)
dep_stack_remove();
}