Skip to content

objtool/klp: Reject changed functions without an ftrace call site

Puranjay Mohan live-patching 2 versions Applied

Status from this message: Queued, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 3 repliesApplied
  2. v13 patches 4 repliesSuperseded

Changes in v2 from the cover letter

- test-special-sections: check __mcount_loc in its own block instead of inside the section loop (Joe)
- Collected Joe's Acked-by on patches 2 and 3

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/3objtool/klp: Build test fixtures with ftracetools/objtool/Documentation/klp-write-tests.txt tools/objtool/tests/generic/test-thinlto-ambiguity.sh tools/objtool/tests/generic/test-thinlto-local.sh +3 more+61 -140 replies
2/3objtool/klp: Reject changed functions without an ftrace call sitetools/objtool/include/objtool/elf.h tools/objtool/klp-diff.c+48 -00 replies
3/3objtool/klp: Add test for changed functions without an ftrace call sitetools/objtool/tests/x86/fixtures/notrace_target.c tools/objtool/tests/x86/test-notrace-target.sh+145 -00 replies

Reviews trailers per patch

2 of 3 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchJoe LawrenceSong Liu
SeriesA-b A-b
1/3
2/3A-b
3/3A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/3] objtool/klp: Reject changed functions without an ftrace call site

Changelog:
v1: https://lore.kernel.org/all/[email protected]/
Changes in v2:
- test-special-sections: check __mcount_loc in its own block instead of inside the section loop (Joe)
- Collected Joe's Acked-by on patches 2 and 3

A changed function without an ftrace call site makes klp-build produce a patch module which fails to load. The kernel's 'inline' implies notrace, so this happens whenever the compiler emits an inline function out of line. Patch 2 makes klp diff reject such functions, patch 3 tests it. Patch 1 builds the test fixtures with ftrace, which patch 2 needs.

Tested on x86_64 with GCC 11 and Clang 22: the objtool klp tests, and klp-build with a vng boot, where a patch module built without the check fails to load with "failed to find location for function".

Note for the arm64 klp-build series: arm64 has no __mcount_loc, so on top of that series this would reject every changed function. It needs mark_traceable_functions() to also handle __patchable_function_entries, using pfe_offset. I can send that on top of the arm64 series.

Puranjay Mohan (3):
objtool/klp: Build test fixtures with ftrace objtool/klp: Reject changed functions without an ftrace call site objtool/klp: Add test for changed functions without an ftrace call
site

 .../objtool/Documentation/klp-write-tests.txt |  9 ++-
 tools/objtool/include/objtool/elf.h           |  1 +
 tools/objtool/klp-diff.c                      | 47 ++++++++++++
 .../tests/generic/test-thinlto-ambiguity.sh   |  3 +-
 .../tests/generic/test-thinlto-local.sh       |  5 +-
 tools/objtool/tests/lib.sh                    | 42 ++++++++++-
 .../tests/x86/fixtures/notrace_target.c       | 71 ++++++++++++++++++
 tools/objtool/tests/x86/test-checksum-alt.sh  |  4 -
 .../objtool/tests/x86/test-notrace-target.sh  | 74 +++++++++++++++++++
 .../tests/x86/test-special-sections.sh        | 12 ++-
 10 files changed, 254 insertions(+), 14 deletions(-)
 create mode 100644 tools/objtool/tests/x86/fixtures/notrace_target.c
 create mode 100755 tools/objtool/tests/x86/test-notrace-target.sh

base-commit: 6ecc854643e6fd6a2d07bc8d83015c7c34a951eb

Signature · 1 line
2.53.0-Meta