Skip to content

objtool/klp: Fix sympos for global/local symbol collisions

Wilson Felipe Pereira live-patching lkml 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 0 repliesNew
  2. v12 patches 1 replySuperseded

Changes in v2 from the cover letter

- Simplify clone_reloc_klp() by unifying klp_find_sympos() below the export/non-export branch (Josh Poimboeuf).
- Rebase onto v7.4-rc4 (b6a9fa34ce41).

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2objtool/klp: Disambiguate global symbols colliding with local symbolstools/objtool/klp-diff.c tools/objtool/klp-symid.c tools/objtool/klp-sympos.c+11 -50 replies
2/2objtool/klp: Add test for global/local symbol name collisionstools/objtool/tests/generic/fixtures/sympos_vmlinux.c tools/objtool/tests/generic/test-sympos-global-dup.sh+105 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] objtool/klp: Fix sympos for global/local symbol collisions

When a defined STB_GLOBAL symbol in one translation unit shares its name with a static (STB_LOCAL) symbol in another translation unit (for example, cgroup_storage_lookup in kernel/bpf/local_storage.c vs kernel/bpf/bpf_cgrp_storage.c), runtime kallsyms lookup counts both symbols together. Emitting sympos 0 for the global symbol causes module load to fail in klp_find_object_symbol() with "unresolvable ambiguity for symbol".

Patch 1 disambiguates defined non-local symbols across .klp.symid generation, klp_find_sympos(), and clone_reloc_klp() (while preserving sympos 0 when unique). Patch 2 adds tests covering both module (.symtab order) and vmlinux (.klp.symid address order) paths, including EXPORT_SYMBOL_FOR_MODULES() exports.

v1 -> v2:
- Simplify clone_reloc_klp() by unifying klp_find_sympos() below the export/non-export branch (Josh Poimboeuf).
- Rebase onto v7.4-rc4 (b6a9fa34ce41).

v1: https://lore.kernel.org/all/[email protected]/

Wilson Felipe Pereira (2):
objtool/klp: Disambiguate global symbols colliding with local symbols objtool/klp: Add test for global/local symbol name collisions

 tools/objtool/klp-diff.c                      |  5 +-
 tools/objtool/klp-symid.c                     |  2 +-
 tools/objtool/klp-sympos.c                    |  9 +-
 .../tests/generic/fixtures/sympos_vmlinux.c   |  6 ++
 .../tests/generic/test-sympos-global-dup.sh   | 99 +++++++++++++++++++
 5 files changed, 116 insertions(+), 5 deletions(-)
 create mode 100755 tools/objtool/tests/generic/test-sympos-global-dup.sh

base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f

Signature · 1 line
2.56.1.750.gf70dc682cf-goog