linux/tools/objtool
Josh Poimboeuf 0c314a881c objtool: Fix stack overflow in validate_branch()
On an allmodconfig kernel compiled with Clang, objtool is segfaulting in
drivers/scsi/qla2xxx/qla2xxx.o due to a stack overflow in
validate_branch().

Due in part to KASAN being enabled, the qla2xxx code has a large number
of conditional jumps, causing objtool to go quite deep in its recursion.

By far the biggest offender of stack usage is the recently added
'prev_state' stack variable in validate_insn(), coming in at 328 bytes.

Move that variable (and its tracing usage) to handle_insn_ops() and make
handle_insn_ops() noinline to keep its stack frame outside the recursive
call chain.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Fixes: fcb268b47a ("objtool: Trace instruction state changes during function validation")
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://patch.msgid.link/21bb161c23ca0d8c942a960505c0d327ca2dc7dc.1764691895.git.jpoimboe@kernel.org
Closes: https://lore.kernel.org/20251201202329.GA3225984@ax162
2025-12-02 17:40:35 +01:00
..
arch objtool: Add Function to get the name of a CPU feature 2025-11-24 20:39:47 +01:00
Documentation Revert "objtool: Warn on functions with ambiguous -ffunction-sections section names" 2025-11-21 10:04:10 +01:00
include/objtool objtool: Add wide output for disassembly 2025-11-24 20:40:48 +01:00
.gitignore objtool: Add Function to get the name of a CPU feature 2025-11-24 20:39:47 +01:00
Build objtool: Add option to trace function validation 2025-11-21 15:30:09 +01:00
builtin-check.c objtool: Add wide output for disassembly 2025-11-24 20:40:48 +01:00
builtin-klp.c objtool/klp: Add post-link subcommand to finalize livepatch modules 2025-10-14 14:50:18 -07:00
check.c objtool: Fix stack overflow in validate_branch() 2025-12-02 17:40:35 +01:00
disas.c objtool: Fix segfault on unknown alternatives 2025-12-01 10:42:27 +01:00
elf.c objtool: Remove second pass of .cold function correlation 2025-11-21 10:04:08 +01:00
klp-diff.c livepatch/klp-build: Introduce klp-build script for generating livepatch modules 2025-10-14 14:50:19 -07:00
klp-post-link.c objtool/klp: Add post-link subcommand to finalize livepatch modules 2025-10-14 14:50:18 -07:00
Makefile objtool: Build with disassembly can fail when including bdf.h 2025-11-27 09:32:46 +01:00
noreturns.h x86/smpboot: Mark native_play_dead() as __noreturn 2025-10-30 08:29:41 -07:00
objtool.c objtool/klp: Add --debug option to show cloning decisions 2025-10-14 14:50:18 -07:00
orc_dump.c objtool: Add annotype() helper 2025-10-14 14:46:49 -07:00
orc_gen.c objtool: Add annotype() helper 2025-10-14 14:46:49 -07:00
special.c objtool: Provide access to feature and flags of group alternatives 2025-11-21 15:30:14 +01:00
sync-check.sh objtool/klp: Introduce klp diff subcommand for diffing object files 2025-10-14 14:50:18 -07:00
trace.c objtool: Improve tracing of alternative instructions 2025-11-21 15:30:11 +01:00
weak.c objtool/klp: Introduce klp diff subcommand for diffing object files 2025-10-14 14:50:18 -07:00