Skip to content

ftrace: host klp and bpf trampoline together

Song Liu bpf live-patching lkml 5 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest4 patches 8 repliesApplied 4/4
  2. v44 patches 11 repliesSuperseded
  3. v34 patches 6 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v25 patches36 repliesSuperseded
v15 patches0 repliesSuperseded

Changes in v5 from the cover letter

1. Cleanup direct_mutex handling in register_ftrace_function. (Steven Rostedt, Petr Mladek).
2. Various smallish fixes. (Steven Rostedt, Petr Mladek).

Patches in v5 All 4 applied

#Subject and filesSizeRepliesApplied
1/4ftrace: Add modify_ftrace_direct_multi_nolockinclude/linux/ftrace.h kernel/trace/ftrace.c+67 -240 repliesApplied
2/4ftrace: Allow IPMODIFY and DIRECT ops on the same functioninclude/linux/ftrace.h kernel/trace/ftrace.c+254 -263 repliesApplied
3/4bpf, x64: Allow to use caller address from stackarch/x86/net/bpf_jit_comp.c include/linux/bpf.h+14 -40 repliesApplied
4/4bpf: Support bpf_trampoline on functions with IPMODIFY (e.g. livepatch)include/linux/bpf.h kernel/bpf/trampoline.c+149 -172 repliesApplied

Reviews trailers per patch

None of the 4 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchSteven Rostedt (Google)Naveen N. Rao
SeriesR-b
1/4
2/4Reported-and-Tested-by
3/4
4/4

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

Read the v5 thread

Cover letter [PATCH v5 bpf-next 0/4] ftrace: host klp and bpf trampoline together

Changes v4 => v5:
1. Cleanup direct_mutex handling in register_ftrace_function. (Steven Rostedt, Petr Mladek).
2. Various smallish fixes. (Steven Rostedt, Petr Mladek).

Changes v3 => v4:
1. Fix build errors for different config. (kernel test robot)

Changes v2 => v3:
1. Major rewrite after discussions with Steven Rostedt. [1]
2. Remove SHARE_IPMODIFY flag from ftrace code. Instead use the callback function to communicate this information. (Steven)
3. Add cleanup_direct_functions_after_ipmodify() to clear SHARE_IPMODIFY on the DIRECT ops when the IPMODIFY ops is removed.

Changes v1 => v2:
1. Fix build errors for different config. (kernel test robot)

Kernel Live Patch (livepatch, or klp) and bpf trampoline are important features for modern systems. This set allows the two to work on the same kernel function as the same time.

live patch uses ftrace with IPMODIFY, while bpf trampoline use direct ftrace. Existing policy does not allow the two to attach to the same kernel function. This is changed by fine tuning ftrace IPMODIFY policy, and allows one IPMODIFY ftrace_ops and one DIRECT ftrace_ops on the same kernel function at the same time. Please see patch 2 and 4 for more details.

Note that, one of the constraint here is to let bpf trampoline use direct call when it is not working on the same function as live patch. This is achieved by allowing ftrace code to ask bpf trampoline to make changes.

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

Jiri Olsa (1):
bpf, x64: Allow to use caller address from stack

Song Liu (3):
ftrace: Add modify_ftrace_direct_multi_nolock
ftrace: Allow IPMODIFY and DIRECT ops on the same function
bpf: Support bpf_trampoline on functions with IPMODIFY (e.g.
livepatch)

 arch/x86/net/bpf_jit_comp.c |  13 +-
 include/linux/bpf.h         |  13 ++
 include/linux/ftrace.h      |  43 +++++
 kernel/bpf/trampoline.c     | 158 +++++++++++++++--
 kernel/trace/ftrace.c       | 328 ++++++++++++++++++++++++++++++------
 5 files changed, 484 insertions(+), 71 deletions(-)

--
2.30.2