summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Lawrence <joe.lawrence@redhat.com>2026-06-26 17:21:39 -0400
committerNamhyung Kim <namhyung@kernel.org>2026-07-03 13:38:08 -0700
commit5a9dd835894cffed85d56aaedc1950bf858ff510 (patch)
tree0fb61da955dec600b52861136123f44845c3e809
parente1065ed188cfe1327863e03143db65425b399210 (diff)
downloadlinux-stable-5a9dd835894cffed85d56aaedc1950bf858ff510.tar.gz
linux-stable-5a9dd835894cffed85d56aaedc1950bf858ff510.zip
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>
-rw-r--r--tools/perf/util/symbol.c4
-rw-r--r--tools/perf/util/symbol.h12
2 files changed, 14 insertions, 2 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index cd379ced19e5..a562702b4841 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -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;
/*
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index a71525335703..d0bac824c79c 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -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"
@@ -46,6 +48,16 @@ static inline bool is_ignored_kernel_symbol(const char *str)
}
/*
+ * 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:
*/