BPF List
 help / color / mirror / Atom feed
* [RFC PATCH bpf-next v3 0/2] ftrace: deprecate the ftrace_enabled disable switch
@ 2026-08-06 15:29 Andrey Grodzovsky
  2026-08-06 15:29 ` [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl Andrey Grodzovsky
  2026-08-06 15:30 ` [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled Andrey Grodzovsky
  0 siblings, 2 replies; 10+ messages in thread
From: Andrey Grodzovsky @ 2026-08-06 15:29 UTC (permalink / raw)
  To: bpf, linux-trace-kernel, live-patching, rostedt, mbenes
  Cc: jolsa, mhiramat, jpoimboe, joe.lawrence, mark.rutland, corbet,
	stable, linux-open-source

This addresses a long-standing issue: kernel.ftrace_enabled=0 silently
disables BPF trampolines (fentry/fexit) and ftrace-based
kprobes/kretprobes. The write succeeds, the hook stops firing with no
error, and re-enabling silently restores it.

The solution chosen is to deny setting this knob to 0 from userspace,
thus preventing this case in the first place. Steven mentioned that the
switch became effectively useless and doesn't serve any meaningful
purpose anymore, and only creates problems for systems that rely on
ftrace, such as Livepatching and eBPF. Any attempt to set it to 0 will
fail with -EOPNOTSUPP. Reading and writing 1 remain unchanged.

Patch 1: the sysctl change plus a doc note.
Patch 2: updates the one selftest that relied on the old disable
behavior.

The original patch-set was a fix to commit 00963a2e75a8 ("bpf: Support
bpf_trampoline on functions with IPMODIFY (e.g. livepatch)"), and so we
would want to see this backported at least to LTS branches starting
with 6.1. But since this is effectively a new behavior and not a bug
fix, I am not sure what the policy is in this case.

Changes since v2:
  - Remove unused ftrace_shutdown_sysctl() and
    is_permanent_ops_registered() functions entirely instead of keeping
    them with __maybe_unused. (Steven)
  - Fix ftrace_disable_supported() to save and restore the original
    kernel.ftrace_enabled value instead of unconditionally forcing it to
    1. (Joe)

[1] https://lore.kernel.org/bpf/20260731175358.3542156-1-andrey.grodzovsky@crowdstrike.com/

Andrey Grodzovsky (2):
  ftrace: deprecate disabling via ftrace_enabled sysctl
  selftests/livepatch: update test-ftrace.sh for deprecated
    ftrace_enabled

 Documentation/trace/ftrace.rst                |  5 +++
 kernel/trace/ftrace.c                         | 43 +++---------------
 .../testing/selftests/livepatch/functions.sh  | 14 ++++++
 .../selftests/livepatch/test-ftrace.sh        | 45 ++++++++++++-------
 4 files changed, 53 insertions(+), 54 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-08-07  7:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-06 15:29 [RFC PATCH bpf-next v3 0/2] ftrace: deprecate the ftrace_enabled disable switch Andrey Grodzovsky
2026-08-06 15:29 ` [RFC PATCH bpf-next v3 1/2] ftrace: deprecate disabling via ftrace_enabled sysctl Andrey Grodzovsky
2026-08-06 15:41   ` sashiko-bot
2026-08-06 21:21   ` Song Liu
2026-08-06 21:52     ` Andrey Grodzovsky
2026-08-06 15:30 ` [RFC PATCH bpf-next v3 2/2] selftests/livepatch: update test-ftrace.sh for deprecated ftrace_enabled Andrey Grodzovsky
2026-08-06 21:18   ` Song Liu
2026-08-06 21:45     ` Andrey Grodzovsky
2026-08-07  0:51       ` Steven Rostedt
2026-08-07  7:17         ` Song Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox