]> git.baikalelectronics.ru Git - kernel.git/commitdiff
objtool: Fix pv_ops noinstr validation
authorPeter Zijlstra <peterz@infradead.org>
Thu, 2 Dec 2021 20:45:34 +0000 (21:45 +0100)
committerBorislav Petkov <bp@suse.de>
Fri, 3 Dec 2021 08:11:42 +0000 (09:11 +0100)
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: 5f2643e372a2 ("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
tools/objtool/elf.c
tools/objtool/objtool.c

index 81a4c543ff7ea5b966b4de08195dea3f9068b1c6..4b384c907027eb4e21cf0997c1cf2c0f5710986c 100644 (file)
@@ -375,6 +375,7 @@ static int read_symbols(struct elf *elf)
                        return -1;
                }
                memset(sym, 0, sizeof(*sym));
+               INIT_LIST_HEAD(&sym->pv_target);
                sym->alias = sym;
 
                sym->idx = i;
index c90c7084e45a9c68b022846189c5155600626551..bdf699f6552bed6432765c7ce37abbd1d520395c 100644 (file)
@@ -153,6 +153,10 @@ void objtool_pv_add(struct objtool_file *f, int idx, struct symbol *func)
            !strcmp(func->name, "_paravirt_ident_64"))
                return;
 
+       /* already added this function */
+       if (!list_empty(&func->pv_target))
+               return;
+
        list_add(&func->pv_target, &f->pv_ops[idx].targets);
        f->pv_ops[idx].clean = false;
 }