Skip to content

Commit 8b00083

Browse files
committed
Merge tag 'objtool-urgent-2020-05-10' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull objtool fix from Thomas Gleixner: "A single fix for objtool to prevent an infinite loop in the jump table search which can be triggered when building the kernel with '-ffunction-sections'" * tag 'objtool-urgent-2020-05-10' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: objtool: Fix infinite loop in find_jump_table()
2 parents bd2049f + 1119d26 commit 8b00083

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tools/objtool/check.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ static struct instruction *next_insn_same_func(struct objtool_file *file,
7272
return find_insn(file, func->cfunc->sec, func->cfunc->offset);
7373
}
7474

75+
static struct instruction *prev_insn_same_sym(struct objtool_file *file,
76+
struct instruction *insn)
77+
{
78+
struct instruction *prev = list_prev_entry(insn, list);
79+
80+
if (&prev->list != &file->insn_list && prev->func == insn->func)
81+
return prev;
82+
83+
return NULL;
84+
}
85+
7586
#define func_for_each_insn(file, func, insn) \
7687
for (insn = find_insn(file, func->sec, func->offset); \
7788
insn; \
@@ -1050,8 +1061,8 @@ static struct rela *find_jump_table(struct objtool_file *file,
10501061
* it.
10511062
*/
10521063
for (;
1053-
&insn->list != &file->insn_list && insn->func && insn->func->pfunc == func;
1054-
insn = insn->first_jump_src ?: list_prev_entry(insn, list)) {
1064+
insn && insn->func && insn->func->pfunc == func;
1065+
insn = insn->first_jump_src ?: prev_insn_same_sym(file, insn)) {
10551066

10561067
if (insn != orig_insn && insn->type == INSN_JUMP_DYNAMIC)
10571068
break;

0 commit comments

Comments
 (0)