]> git.ipfire.org Git - thirdparty/linux.git/commit
objtool: Fix stack overflow in validate_branch()
authorJosh Poimboeuf <jpoimboe@kernel.org>
Tue, 2 Dec 2025 16:16:28 +0000 (08:16 -0800)
committerIngo Molnar <mingo@kernel.org>
Tue, 2 Dec 2025 16:40:35 +0000 (17:40 +0100)
commit0c314a881cac61a80a0e05309fafd48c55dd3afc
treea51112f81eb58c38596858f6e84a2c5197adc195
parent4a26e7032d7d57c998598c08a034872d6f0d3945
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: fcb268b47a2f ("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
tools/objtool/check.c