linux/tools/objtool
Josh Poimboeuf 15fa203ef9 objtool/klp: Fix symbol resolution for duplicate data symbols
find_sympos() calculates a sympos used by livepatch to disambiguate
duplicately-named symbols.  For function symbols, there's a hack which
counts .text.unlikely symbols before other .text symbols, matching the
linker script's section ordering.

Not only is the hack fragile, data symbols can have the same problem.
So for example, adding a reference to pwq_cache in
ep_unregister_pollwait() can trigger a corrupt sympos and a relocation
to the wrong pwq_cache symbol in the livepatch module, resulting in a
crash or undefined behavior.

Remove the existing hack in favor of a fully deterministic solution,
using the new .klp.symid table to derive the symbol-to-id mapping from
the original vmlinux.o and the id-to-address mapping from the
corresponding vmlinux, which can then be used to determine the exact
sympos associated with the original vmlinux.

Modules don't need any special treatment: the .ko has the same
section/symbol ordering as the original whole-archive symbol table.

Fixes: dd590d4d57 ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Reported-by: Ben Procknow <bprockno@redhat.com>
Reported-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: live-patching@vger.kernel.org
Link: https://lore.kernel.org/20260710153042.3156788-1-joe.lawrence@redhat.com
Link: https://lore.kernel.org/20260724221730.3126529-1-joe.lawrence@redhat.com
Link: https://patch.msgid.link/919785e3bf2245db02ff6391e735d9cb139170b1.1785727106.git.jpoimboe@kernel.org
2026-08-03 07:12:39 +02:00
..
arch objtool/klp: Fix position-dependent checksums for non-relocated jumps/calls 2026-05-04 21:16:06 -07:00
Documentation Revert "objtool: Warn on functions with ambiguous -ffunction-sections section names" 2025-11-21 10:04:10 +01:00
include/objtool objtool/klp: Fix symbol resolution for duplicate data symbols 2026-08-03 07:12:39 +02:00
.gitignore objtool: Add Function to get the name of a CPU feature 2025-11-24 20:39:47 +01:00
Build objtool/klp: Fix symbol resolution for duplicate data symbols 2026-08-03 07:12:39 +02:00
builtin-check.c objtool/klp: Add .klp.symid for sympos disambiguation 2026-08-03 07:12:39 +02:00
builtin-klp.c objtool/klp: Add "objtool klp checksum" subcommand 2026-05-04 21:16:05 -07:00
check.c objtool/klp: Add .klp.symid for sympos disambiguation 2026-08-03 07:12:39 +02:00
disas.c objtool: Add insn_sym() helper 2026-05-04 21:16:06 -07:00
elf.c objtool/klp: Fix false module dependencies caused by dead relocs 2026-08-03 07:12:38 +02:00
klp-checksum.c objtool/klp: Fix position-dependent checksums for non-relocated jumps/calls 2026-05-04 21:16:06 -07:00
klp-diff.c objtool/klp: Fix symbol resolution for duplicate data symbols 2026-08-03 07:12:39 +02:00
klp-post-link.c objtool/klp: Add post-link subcommand to finalize livepatch modules 2025-10-14 14:50:18 -07:00
klp-symid.c objtool/klp: Add .klp.symid for sympos disambiguation 2026-08-03 07:12:39 +02:00
klp-sympos.c objtool/klp: Fix symbol resolution for duplicate data symbols 2026-08-03 07:12:39 +02:00
Makefile objtool: Include libsubcmd headers directly from source tree 2026-05-04 21:16:04 -07:00
noreturns.h x86/smpboot: Mark native_play_dead() as __noreturn 2025-10-30 08:29:41 -07:00
objtool.c objtool/klp: Add correlation debugging output 2026-05-04 21:16:06 -07:00
orc_dump.c objtool: Add annotype() helper 2025-10-14 14:46:49 -07:00
orc_gen.c objtool: Add annotype() helper 2025-10-14 14:46:49 -07:00
signal.c objtool: Add more robust signal error handling, detect and warn about stack overflows 2025-12-03 19:42:37 +01:00
special.c objtool: Provide access to feature and flags of group alternatives 2025-11-21 15:30:14 +01:00
sync-check.sh objtool/klp: Introduce klp diff subcommand for diffing object files 2025-10-14 14:50:18 -07:00
trace.c objtool: Add insn_sym() helper 2026-05-04 21:16:06 -07:00
weak.c objtool/klp: Introduce klp diff subcommand for diffing object files 2025-10-14 14:50:18 -07:00