Skip to content

Commit 9a73f08

Browse files
committed
objtool: Fix another stack overflow in validate_branch()
The insn state is getting saved on the stack twice for each recursive iteration. No need for that, once is enough. Fixes the following reported stack overflow: drivers/scsi/qla2xxx/qla_dbg.o: error: SIGSEGV: objtool stack overflow! Segmentation fault Fixes: 7058984 ("objtool: Add option to trace function validation") Reported-by: Arnd Bergmann <arnd@arndb.de> Closes: https://lore.kernel.org/90956545-2066-46e3-b547-10c884582eb0@app.fastmail.com Link: https://patch.msgid.link/8b97f62d083457f3b0a29a424275f7957dd3372f.1772821683.git.jpoimboe@kernel.org Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
1 parent 7fdaa64 commit 9a73f08

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

tools/objtool/check.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3748,7 +3748,7 @@ static void checksum_update_insn(struct objtool_file *file, struct symbol *func,
37483748
static int validate_branch(struct objtool_file *file, struct symbol *func,
37493749
struct instruction *insn, struct insn_state state);
37503750
static int do_validate_branch(struct objtool_file *file, struct symbol *func,
3751-
struct instruction *insn, struct insn_state state);
3751+
struct instruction *insn, struct insn_state *state);
37523752

37533753
static int validate_insn(struct objtool_file *file, struct symbol *func,
37543754
struct instruction *insn, struct insn_state *statep,
@@ -4013,7 +4013,7 @@ static int validate_insn(struct objtool_file *file, struct symbol *func,
40134013
* tools/objtool/Documentation/objtool.txt.
40144014
*/
40154015
static int do_validate_branch(struct objtool_file *file, struct symbol *func,
4016-
struct instruction *insn, struct insn_state state)
4016+
struct instruction *insn, struct insn_state *state)
40174017
{
40184018
struct instruction *next_insn, *prev_insn = NULL;
40194019
bool dead_end;
@@ -4044,7 +4044,7 @@ static int do_validate_branch(struct objtool_file *file, struct symbol *func,
40444044
return 1;
40454045
}
40464046

4047-
ret = validate_insn(file, func, insn, &state, prev_insn, next_insn,
4047+
ret = validate_insn(file, func, insn, state, prev_insn, next_insn,
40484048
&dead_end);
40494049

40504050
if (!insn->trace) {
@@ -4055,7 +4055,7 @@ static int do_validate_branch(struct objtool_file *file, struct symbol *func,
40554055
}
40564056

40574057
if (!dead_end && !next_insn) {
4058-
if (state.cfi.cfa.base == CFI_UNDEFINED)
4058+
if (state->cfi.cfa.base == CFI_UNDEFINED)
40594059
return 0;
40604060
if (file->ignore_unreachables)
40614061
return 0;
@@ -4080,7 +4080,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
40804080
int ret;
40814081

40824082
trace_depth_inc();
4083-
ret = do_validate_branch(file, func, insn, state);
4083+
ret = do_validate_branch(file, func, insn, &state);
40844084
trace_depth_dec();
40854085

40864086
return ret;

0 commit comments

Comments
 (0)