On Wed 2026-06-24 16:12:54, Joe Lawrence wrote:
> Livepatch modules contain special symbols (prefixed by ".klp.sym.") that
> act as relocation placeholders.  Once resolved, they point to the same
> addresses as the original kernel symbols they reference. [1]
> 
> These special symbols confuse the 'vmlinux symtab matches kallsyms' perf
> test as kallsyms may report multiple symbols sharing a single kernel
> address.  For example:
> 
>   kallsyms (without livepatch)
>   ----------------------------
>   ffffffff81a41110 T __pfx_arch_release_task_struct
> > ffffffff81a41120 T arch_release_task_struct
>   ffffffff81a41140 T __pfx_exit_thread
>   ffffffff81a41150 T exit_thread
> 
>   kallsyms (with livepatch loaded)
>   ---------------------------------
>   ffffffff81a41110 T __pfx_arch_release_task_struct
> > ffffffff81a41120 T arch_release_task_struct
>   ffffffff81a41140 T __pfx_exit_thread
>   ffffffff81a41150 T exit_thread
> > ffffffff81a41120 w .klp.sym.vmlinux.arch_release_task_struct,0  
> > [kpatch_5_14_0_570_94_1_1_3]
> 
> When perf loads kallsyms, both symbols are inserted into the
> symbol table at the same address, corrupting symbol end-address
> calculations and causing test failures.
> 
> Filter out symbols prefixed with ".klp.sym." when loading kallsyms, as
> they alias existing kernel symbols.
> 
> Link: 
> https://docs.kernel.org/livepatch/module-elf-format.html#livepatch-symbols [1]
> Reported-and-tested-by: Ben Procknow <[email protected]>
> Signed-off-by: Joe Lawrence <[email protected]>
> ---
>  tools/perf/util/symbol.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> >From Ben's tests:
> 
>   Without patch:
>   ./tools/perf/perf test 1
>    1: vmlinux symtab matches kallsyms                                 : 
> FAILED!
> 
>   With patch:
>   ./tools/perf/perf test 1
>    1: vmlinux symtab matches kallsyms                                 : Ok
> 
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index fcaeeddbbb6b..eeaed3f5cf50 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -774,6 +774,10 @@ static int map__process_kallsym_symbol(void *arg, const 
> char *name,
>       if (name[0] == '$')
>               return 0;

It seems that the above checks has been moved into is_ignored_kernel_symbol(),
in the current Linus' tree, see
https://lore.kernel.org/lkml/[email protected]/

> +     /* Ignore livepatch symbols */
> +     if (strstarts(name, ".klp.sym."))
> +             return 0;

I guess that this check should be moved there as well.

Nit: It might be possible to include <linux/livepatch_external.h>
     and use KLP_SYM_PREFIX instead of ".klp.sym."

> +
>       /*
>        * module symbols are not sorted so we add all
>        * symbols, setting length to 0, and rely on

Best Regards,
Petr

Reply via email to