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

From
Song Liu <song@kernel.org>
Date
2026-10-23 17:44:40
Reply to
Puranjay Mohan, 2026-10-22
On Thu, Oct 22, 2026 at 10:16 AM Puranjay Mohan [off-list ref] wrote:
Changelog:
v1: https://lore.kernel.org/all/20261022122544.125305-1-puranjay@kernel.org/ (local)
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
LGTM. For the set:

Acked-by: Song Liu <song@kernel.org>

 .../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
--
2.53.0-Meta
Thread (6 messages) 6 messages, 3 authors, last reply 24d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help