mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 15:43:08 -04:00
perf symbols: skip livepatch symbols when loading kallsyms
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: Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com> Acked-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
committed by
Namhyung Kim
parent
e1065ed188
commit
5a9dd83589
@@ -880,8 +880,8 @@ static int map__process_kallsym_symbol(void *arg, const char *name,
|
||||
if (!symbol_type__filter(type))
|
||||
return 0;
|
||||
|
||||
/* Ignore mapping symbols in kallsyms */
|
||||
if (is_ignored_kernel_symbol(name))
|
||||
/* Ignore mapping and livepatch symbols in kallsyms */
|
||||
if (is_ignored_kernel_symbol(name) || is_livepatch_symbol(name))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
#include <stdint.h>
|
||||
#include <stdatomic.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/livepatch_external.h>
|
||||
#include <linux/rbtree.h>
|
||||
#include <linux/string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "addr_location.h"
|
||||
@@ -45,6 +47,16 @@ static inline bool is_ignored_kernel_symbol(const char *str)
|
||||
return str[0] == '$';
|
||||
}
|
||||
|
||||
/*
|
||||
* Livepatch symbols (.klp.sym.*) are relocation placeholders whose resolved
|
||||
* addresses alias existing kernel symbols. They carry a [module] tag which
|
||||
* confuses module boundary tracking and symbol table lookups.
|
||||
*/
|
||||
static inline bool is_livepatch_symbol(const char *str)
|
||||
{
|
||||
return strstarts(str, KLP_SYM_PREFIX);
|
||||
}
|
||||
|
||||
/*
|
||||
* libelf 0.8.x and earlier do not support ELF_C_READ_MMAP;
|
||||
* for newer versions we can use mmap to reduce memory usage:
|
||||
|
||||
Reference in New Issue
Block a user