]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ftrace: bpf: Fix IPMODIFY + DIRECT in modify_ftrace_direct()
authorSong Liu <song@kernel.org>
Mon, 27 Oct 2025 17:50:22 +0000 (10:50 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 4 Nov 2025 01:22:06 +0000 (17:22 -0800)
commit3e9a18e1c3e931abecf501cbb23d28d69f85bb56
tree376f4ad514b7b1d0499dc9abc912d84dc7e245a6
parent56b3c85e153b84f27e6cff39623ba40a1ad299d3
ftrace: bpf: Fix IPMODIFY + DIRECT in modify_ftrace_direct()

ftrace_hash_ipmodify_enable() checks IPMODIFY and DIRECT ftrace_ops on
the same kernel function. When needed, ftrace_hash_ipmodify_enable()
calls ops->ops_func() to prepare the direct ftrace (BPF trampoline) to
share the same function as the IPMODIFY ftrace (livepatch).

ftrace_hash_ipmodify_enable() is called in register_ftrace_direct() path,
but not called in modify_ftrace_direct() path. As a result, the following
operations will break livepatch:

1. Load livepatch to a kernel function;
2. Attach fentry program to the kernel function;
3. Attach fexit program to the kernel function.

After 3, the kernel function being used will not be the livepatched
version, but the original version.

Fix this by adding __ftrace_hash_update_ipmodify() to
__modify_ftrace_direct() and adjust some logic around the call.

Signed-off-by: Song Liu <song@kernel.org>
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20251027175023.1521602-3-song@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/ftrace.c