Skip to content

Commit 988f016

Browse files
Peter Zijlstrasuryasaimadhu
authored andcommitted
objtool: Fix pv_ops noinstr validation
Boris reported that in one of his randconfig builds, objtool got infinitely stuck. Turns out there's trivial list corruption in the pv_ops tracking when a function is both in a static table and in a code assignment. Avoid re-adding function to the pv_ops[] lists when they're already on it. Fixes: db2b0c5 ("objtool: Support pv_opsindirect calls for noinstr") Reported-by: Borislav Petkov <bp@alien8.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Borislav Petkov <bp@suse.de> Tested-by: Borislav Petkov <bp@alien8.de> Link: https://lkml.kernel.org/r/20211202204534.GA16608@worktop.programming.kicks-ass.net
1 parent b50db70 commit 988f016

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

tools/objtool/elf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ static int read_symbols(struct elf *elf)
375375
return -1;
376376
}
377377
memset(sym, 0, sizeof(*sym));
378+
INIT_LIST_HEAD(&sym->pv_target);
378379
sym->alias = sym;
379380

380381
sym->idx = i;

tools/objtool/objtool.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ void objtool_pv_add(struct objtool_file *f, int idx, struct symbol *func)
153153
!strcmp(func->name, "_paravirt_ident_64"))
154154
return;
155155

156+
/* already added this function */
157+
if (!list_empty(&func->pv_target))
158+
return;
159+
156160
list_add(&func->pv_target, &f->pv_ops[idx].targets);
157161
f->pv_ops[idx].clean = false;
158162
}

0 commit comments

Comments
 (0)