Commit 988f0168 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Borislav Petkov

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: db2b0c5d ("objtool: Support pv_opsindirect calls for noinstr")
Reported-by: default avatarBorislav Petkov <bp@alien8.de>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Tested-by: default avatarBorislav Petkov <bp@alien8.de>
Link: https://lkml.kernel.org/r/20211202204534.GA16608@worktop.programming.kicks-ass.net
parent b50db709
...@@ -375,6 +375,7 @@ static int read_symbols(struct elf *elf) ...@@ -375,6 +375,7 @@ static int read_symbols(struct elf *elf)
return -1; return -1;
} }
memset(sym, 0, sizeof(*sym)); memset(sym, 0, sizeof(*sym));
INIT_LIST_HEAD(&sym->pv_target);
sym->alias = sym; sym->alias = sym;
sym->idx = i; sym->idx = i;
......
...@@ -153,6 +153,10 @@ void objtool_pv_add(struct objtool_file *f, int idx, struct symbol *func) ...@@ -153,6 +153,10 @@ void objtool_pv_add(struct objtool_file *f, int idx, struct symbol *func)
!strcmp(func->name, "_paravirt_ident_64")) !strcmp(func->name, "_paravirt_ident_64"))
return; return;
/* already added this function */
if (!list_empty(&func->pv_target))
return;
list_add(&func->pv_target, &f->pv_ops[idx].targets); list_add(&func->pv_target, &f->pv_ops[idx].targets);
f->pv_ops[idx].clean = false; f->pv_ops[idx].clean = false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment