Skip to content

objtool/klp: Some klp-build fixes and improvements

Josh Poimboeuf live-patching lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest53 patches 49 repliesIn review
  2. v148 patches 104 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/53objtool/klp: Fix is_uncorrelated_static_local() for Clangtools/objtool/klp-diff.c+23 -100 replies
2/53objtool/klp: Fix .data..once static local non-correlationtools/objtool/klp-diff.c+2 -10 replies
3/53objtool/klp: Don't correlate __ADDRESSABLE() symbolstools/objtool/klp-diff.c+10 -01 reply
4/53objtool/klp: Don't correlate absolute symbolstools/objtool/klp-diff.c+10 -00 replies
5/53objtool/klp: Don't correlate __initstub__ symbolstools/objtool/klp-diff.c+8 -20 replies
6/53objtool/klp: Don't report uncorrelated functions as newtools/objtool/klp-diff.c+2 -20 replies
7/53objtool/klp: Improve local label checktools/objtool/klp-diff.c+7 -71 reply
8/53objtool/klp: Fix create_fake_symbols() skipping entsize-based sectionstools/objtool/klp-diff.c+2 -20 replies
9/53objtool: Replace iterator callback with for_each_sym_by_mangled_name()tools/objtool/elf.c tools/objtool/include/objtool/elf.h tools/objtool/klp-diff.c+60 -822 replies
10/53objtool/klp: Fix --debug-checksum for duplicate symbol namestools/objtool/check.c tools/objtool/include/objtool/elf.h+15 -51 reply
11/53objtool/klp: Fix handling of zero-length .altinstr_replacement sectionstools/objtool/klp-diff.c+12 -10 replies
12/53objtool/klp: Fix cloning of zero-length section symbolstools/objtool/klp-diff.c+1 -10 replies
13/53objtool/klp: Fix XXH3 state memory leaktools/objtool/include/objtool/checksum.h+1 -00 replies
14/53objtool/klp: Fix extraction of text annotations for alternativestools/objtool/klp-diff.c+28 -50 replies
15/53objtool/klp: Fix kCFI trap handlingtools/objtool/klp-diff.c+1 -00 replies
16/53objtool/klp: Fix relocation conversion failures for R_X86_64_NONEtools/objtool/klp-diff.c+3 -00 replies
17/53objtool: Move mark_rodata() to elf.ctools/objtool/check.c tools/objtool/elf.c tools/objtool/include/objtool/elf.h+21 -80 replies
18/53objtool/klp: Simplify reloc symbol conversiontools/objtool/klp-diff.c+28 -482 replies
19/53objtool/klp: Fix pointer comparisons for rodata objectstools/objtool/elf.c tools/objtool/include/objtool/elf.h tools/objtool/klp-diff.c+28 -22 replies
20/53objtool/klp: Don't correlate .rodata.cst* constant pool objectstools/objtool/klp-diff.c+16 -14 replies
21/53objtool/klp: Fix reloc corruption in convert_reloc_sym_to_secsym()tools/objtool/klp-diff.c+1 -12 replies
22/53objtool: Fix reloc hash collision in find_reloc_by_dest_range()tools/objtool/elf.c+4 -30 replies
23/53klp-build: Fix hang on out-of-date .configscripts/livepatch/klp-build+6 -12 replies
24/53klp-build: Fix checksum comparison for changed offsetsscripts/livepatch/klp-build+23 -72 replies
25/53klp-build: Don't use errexitscripts/livepatch/klp-build+2 -30 replies
26/53klp-build: Validate patch file existencescripts/livepatch/klp-build+5 -00 replies
27/53klp-build: Suppress excessive fuzz output by defaultscripts/livepatch/klp-build+13 -60 replies
28/53klp-build: Fix patch cleanup on interruptscripts/livepatch/klp-build+2 -21 reply
29/53klp-build: Reject patches to vDSOscripts/livepatch/klp-build+1 -11 reply
30/53klp-build: Reject patches to realmodescripts/livepatch/klp-build+1 -11 reply
31/53klp-build: Print "objtool klp diff" command in verbose modescripts/livepatch/klp-build+1 -01 reply
32/53klp-build: Remove redundant SRC and OBJ variablesscripts/livepatch/klp-build+28 -392 replies
33/53objtool/klp: Don't set sym->file for section symbolstools/objtool/elf.c+1 -11 reply
34/53objtool: Include libsubcmd headers directly from source treetools/objtool/Makefile+2 -21 reply
35/53objtool/klp: Create empty checksum sections for function-less object filestools/objtool/check.c+0 -31 reply
36/53objtool/klp: Handle Clang .data..Lanon anonymous data sectionstools/objtool/klp-diff.c+4 -31 reply
37/53objtool: Add is_alias_sym() helpertools/objtool/check.c tools/objtool/include/objtool/elf.h+8 -31 reply
38/53objtool: Add is_cold_func() helpertools/objtool/check.c tools/objtool/include/objtool/elf.h tools/objtool/klp-diff.c+10 -42 replies
39/53objtool/klp: Extricate checksum calculation from validate_branch()tools/objtool/check.c tools/objtool/include/objtool/checksum.h+80 -321 reply
40/53objtool: Consolidate file decoding into decode_file()tools/objtool/check.c tools/objtool/include/objtool/check.h+22 -191 reply
41/53objtool/klp: Add "objtool klp checksum" subcommandtools/objtool/Build tools/objtool/builtin-klp.c tools/objtool/check.c +5 more+269 -2051 reply
42/53klp-build: Use "objtool klp checksum" subcommandscripts/livepatch/klp-build+64 -291 reply
43/53objtool/klp: Remove "objtool --checksum"scripts/livepatch/klp-build tools/objtool/builtin-check.c tools/objtool/check.c+5 -271 reply
44/53klp-build: Validate short-circuit prerequisitesscripts/livepatch/klp-build+18 -02 replies
45/53objtool/klp: Calculate object checksumstools/objtool/include/objtool/checksum.h tools/objtool/include/objtool/warn.h tools/objtool/klp-checksum.c +1 more+117 -472 replies
46/53objtool/klp: Rewrite symbol correlation algorithmtools/objtool/klp-diff.c+385 -1362 replies
47/53objtool/klp: Add correlation debugging outputtools/objtool/include/objtool/warn.h tools/objtool/klp-diff.c tools/objtool/objtool.c+45 -161 reply
48/53objtool: Add insn_sym() helpertools/objtool/check.c tools/objtool/disas.c tools/objtool/include/objtool/check.h +2 more+49 -381 reply
49/53objtool/klp: Fix position-dependent checksums for non-relocated jumps/callstools/objtool/arch/x86/decode.c tools/objtool/include/objtool/arch.h tools/objtool/include/objtool/check.h +1 more+67 -91 reply
50/53objtool: Grow __cfi_* prefix symbols for all CFI+CALL_PADDINGarch/x86/Kconfig lib/Kconfig.debug scripts/Makefile.lib +5 more+84 -210 replies
51/53objtool/klp: Fix kCFI prefix finding/cloningtools/objtool/include/objtool/elf.h+2 -21 reply
52/53objtool: Improve and simplify prefix symbol detectiontools/objtool/check.c+21 -690 replies
53/53objtool/klp: Cache dont_correlate() resulttools/objtool/include/objtool/elf.h tools/objtool/klp-diff.c+18 -121 reply

Reviews trailers per patch

51 of 53 patches have a Reviewed-by or Acked-by.

PatchSong LiuMiroslav BenesPeter Zijlstra (Intel)
1/53A-b R-b
2/53A-b R-b
3/53A-b R-b
4/53A-b R-b
5/53A-b R-b
6/53A-b R-b
7/53A-b
8/53A-b R-b
9/53A-b R-b
10/53A-b R-b
11/53A-b R-b
12/53A-b R-b
13/53A-b R-b
14/53A-b R-b
15/53A-b R-b
16/53A-b R-b
17/53A-b R-b A-b
18/53A-b R-b
19/53A-b R-b
20/53A-b R-b
21/53A-b R-b
22/53A-b R-b A-b
23/53A-b R-b
24/53A-b R-b
25/53A-b R-b
26/53A-b R-b
27/53A-b R-b
28/53A-b R-b
29/53A-b R-b
30/53A-b R-b
31/53A-b R-b
32/53A-b R-b
33/53A-b R-b A-b
34/53A-b R-b
35/53A-b R-b
36/53A-b R-b
37/53A-b R-b A-b
38/53A-b R-b
39/53A-b R-b
40/53A-b R-b A-b
41/53A-b R-b
42/53A-b R-b
43/53A-b R-b
44/53A-b R-b
45/53A-b R-b
46/53A-b R-b
47/53A-b R-b
48/53A-b
49/53A-b
50/53
51/53A-b
52/53
53/53A-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 00/53] objtool/klp: Some klp-build fixes and improvements

Changes since v1 (https://lore.kernel.org/[email protected]):

- Add comment for find_reloc_by_dest_range() first-match behavior [Peter]
- Simplify is_cold_func() [Peter]
- Grow __cfi_ symbols [Peter]
- Rename "Ignore __UNIQUE_ID_*() PCI stub functions" to more general "Don't report uncorrelated functions as new" [Song]
- Move rodata non-correlation into pointer-comparison fix [Miroslav]
- Add comments for convert_reloc_sym() return values [Song]
- Remove redundant SRC/OBJ variables [Song]
- Use "if (mismatch) {} else" in for_each_sym_by_*() [Song]
- Flatten nested if-else chain in short-circuit validation [Song]
- Add comments with examples to symbol correlation algorithm [Song]
- Move callback refactor to earlier in the patch set [Miroslav]
- Fix reloc corruption in convert_reloc_sym_to_secsym() [Sashiko]
- Include offset in object checksum hashing [Sashiko]
- Fix klp-build checksum comparison output for added/removed instructions [Sashiko]
- Fix kCFI prefix finding/cloning
- Add reloc symbol conversion simplification cleanup
- Improve local label check for uncorrelated symbols
- Drop "Make function prefix handling more generic" for now (refactored version will come with arm64 patches)
- Refactor inline alternative cloning into separate clone_inline_alternatives()
- Add Acked-by/Reviewed-by tags

---

While working on the (upcoming) arm64 support, I ended up shaking out a lot of bugs by tested several patches on a variety of configs (distro, LTO, FineIBT, kCFI, etc).

While arm64 support seems to be working well, I decided to leave those patches out of this set to try to keep the number of patches "reasonable".

And these stand alone as nice improvements for x86 anyway.

Full arm64 support (this set + more) can be found here:

git://git.kernel.org/pub/scm/linux/kernel/git/jpoimboe/linux.git klp-build-arm64

Joe Lawrence (2):
objtool/klp: Fix is_uncorrelated_static_local() for Clang objtool/klp: Fix create_fake_symbols() skipping entsize-based sections

Josh Poimboeuf (51):
objtool/klp: Fix .data..once static local non-correlation objtool/klp: Don't correlate __ADDRESSABLE() symbols objtool/klp: Don't correlate absolute symbols
objtool/klp: Don't correlate __initstub__ symbols objtool/klp: Don't report uncorrelated functions as new objtool/klp: Improve local label check
objtool: Replace iterator callback with for_each_sym_by_mangled_name() objtool/klp: Fix --debug-checksum for duplicate symbol names objtool/klp: Fix handling of zero-length .altinstr_replacement
sections
objtool/klp: Fix cloning of zero-length section symbols objtool/klp: Fix XXH3 state memory leak
objtool/klp: Fix extraction of text annotations for alternatives objtool/klp: Fix kCFI trap handling
objtool/klp: Fix relocation conversion failures for R_X86_64_NONE
objtool: Move mark_rodata() to elf.c
objtool/klp: Simplify reloc symbol conversion
objtool/klp: Fix pointer comparisons for rodata objects objtool/klp: Don't correlate .rodata.cst* constant pool objects objtool/klp: Fix reloc corruption in convert_reloc_sym_to_secsym()
objtool: Fix reloc hash collision in find_reloc_by_dest_range()
klp-build: Fix hang on out-of-date .config
klp-build: Fix checksum comparison for changed offsets
klp-build: Don't use errexit
klp-build: Validate patch file existence
klp-build: Suppress excessive fuzz output by default
klp-build: Fix patch cleanup on interrupt
klp-build: Reject patches to vDSO
klp-build: Reject patches to realmode
klp-build: Print "objtool klp diff" command in verbose mode
klp-build: Remove redundant SRC and OBJ variables objtool/klp: Don't set sym->file for section symbols
objtool: Include libsubcmd headers directly from source tree objtool/klp: Create empty checksum sections for function-less object
files
objtool/klp: Handle Clang .data..Lanon anonymous data sections
objtool: Add is_alias_sym() helper
objtool: Add is_cold_func() helper
objtool/klp: Extricate checksum calculation from validate_branch()
objtool: Consolidate file decoding into decode_file() objtool/klp: Add "objtool klp checksum" subcommand
klp-build: Use "objtool klp checksum" subcommand objtool/klp: Remove "objtool --checksum"
klp-build: Validate short-circuit prerequisites objtool/klp: Calculate object checksums
objtool/klp: Rewrite symbol correlation algorithm objtool/klp: Add correlation debugging output
objtool: Add insn_sym() helper
objtool/klp: Fix position-dependent checksums for non-relocated
jumps/calls
objtool: Grow __cfi_* prefix symbols for all CFI+CALL_PADDING objtool/klp: Fix kCFI prefix finding/cloning
objtool: Improve and simplify prefix symbol detection objtool/klp: Cache dont_correlate() result

 arch/x86/Kconfig                         |   4 -
 lib/Kconfig.debug                        |   2 +-
 scripts/Makefile.lib                     |   7 +-
 scripts/livepatch/klp-build              | 250 ++++---
 tools/objtool/Build                      |   2 +-
 tools/objtool/Makefile                   |   4 +-
 tools/objtool/arch/x86/decode.c          |  17 +-
 tools/objtool/builtin-check.c            |  26 +-
 tools/objtool/builtin-klp.c              |   1 +
 tools/objtool/check.c                    | 412 ++++-------
 tools/objtool/disas.c                    |  22 +-
 tools/objtool/elf.c                      | 124 ++--
 tools/objtool/include/objtool/arch.h     |   3 +
 tools/objtool/include/objtool/builtin.h  |   7 +-
 tools/objtool/include/objtool/check.h    |  34 +-
 tools/objtool/include/objtool/checksum.h |  53 +-
 tools/objtool/include/objtool/elf.h      |  59 +-
 tools/objtool/include/objtool/klp.h      |   1 +
 tools/objtool/include/objtool/warn.h     |  57 +-
 tools/objtool/klp-checksum.c             | 347 ++++++++++
 tools/objtool/klp-diff.c                 | 826 ++++++++++++++++-------
 tools/objtool/objtool.c                  |   3 -
 tools/objtool/trace.c                    |   8 +-
 23 files changed, 1493 insertions(+), 776 deletions(-)
 create mode 100644 tools/objtool/klp-checksum.c
Signature · 1 line
2.53.0