[PATCH v2 0/3] powerpc/ftrace: Fix livepatch module OOL ftrace corruption

Joe Lawrence joe.lawrence at redhat.com
Sat Sep 13 00:27:37 AEST 2025


This patch series fixes a couple of bugs in the powerpc64 out-of-line
(OOL) ftrace support for modules, and follows up with a patch to
simplify the module .stubs allocation code. An analysis of the module
stub area corruption that prompted this work can be found in the v1
thread [1].

The first two patches fix bugs introduced by commit eec37961a56a
("powerpc64/ftrace: Move ftrace sequence out of line"). The first,
suggested by Naveen, ensures that a NOP'd ftrace call site has its
ftrace_ops record updated correctly. The second patch corrects a loop in
setup_ftrace_ool_stubs() to ensure all required stubs are reserved, not
just the first. Together, these bugs lead to potential corruption of the
OOL ftrace stubs area for livepatch modules.

The final patch replaces the sentinel-based allocation in the module
.stubs section with an explicit counter. This improves clarity and helps
prevent similar problems in the future.

Changes since v1: https://lore.kernel.org/live-patching/df7taxdxpbo4qfn7lniggj5o4ili6kweg4nytyb2fwwwgmnyo4@halp5gf244nn/T/

- Split into parts: bug fix x2, code cleanup
- Call ftrace_rec_set_nop_ops() from ftrace_init_nop() [Naveen]
- Update commit msg on cleanup patch [Naveen]

Joe Lawrence (3):
  powerpc/ftrace: ensure ftrace record ops are always set for NOPs
  powerpc64/modules: correctly iterate over stubs in
    setup_ftrace_ool_stubs
  powerpc64/modules: replace stub allocation sentinel with an explicit
    counter

 arch/powerpc/include/asm/module.h  |  1 +
 arch/powerpc/kernel/module_64.c    | 26 ++++++++------------------
 arch/powerpc/kernel/trace/ftrace.c | 10 ++++++++--
 3 files changed, 17 insertions(+), 20 deletions(-)

-- 
2.51.0



More information about the Linuxppc-dev mailing list