mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/4] bpf: Per-task recursion follow-ups for struct_ops and PREEMPT_RT
@ 2026-12-02 13:15 Mike Bazov via B4 Relay
  2026-12-02 13:15 ` [PATCH bpf-next 1/4] bpf: Refuse struct_ops programs with a private stack in prog arrays Mike Bazov via B4 Relay
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Mike Bazov via B4 Relay @ 2026-12-02 13:15 UTC (permalink / raw)
  To: bpf, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
	Song Liu, Yonghong Song, Jiri Olsa, John Fastabend,
	Emil Tsalapatis, Ihor Solodrai, Steven Rostedt, Masami Hiramatsu,
	Mathieu Desnoyers, JP Kobryn, linux-trace-kernel, linux-kernel,
	Mike Bazov

Two follow-ups to "bpf: Check recursion per task for preemptible
programs", per Alexei's review [1].

Patch 1 fixes an existing hole: a struct_ops program with a private
stack can be the target of a tail call, which enters it past the
trampoline and its recursion check. The caller is a struct_ops program
of the same op without a private stack, so it has no recursion check,
and two tasks on one CPU can run the target on the same private stack.
Such a program is now refused as a prog array element.

Patch 2 keeps marked programs preemptible on PREEMPT_RT: instead of
disabling preemption, a per-CPU counter refuses another run of the
program on the CPU, and the refused run is counted as a recursion
miss.

  1. bpf: Refuse struct_ops programs with a private stack in prog arrays
  2. bpf: Keep a per-CPU counter for marked programs on PREEMPT_RT
  3. selftests/bpf: Test private-stack struct_ops progs in prog arrays
  4. selftests/bpf: Expect marked programs to drop B on PREEMPT_RT

Testing, x86-64, with and without PREEMPT_RT:

With the series, private_stack_tail_call and the trampoline_preempt
subtests pass on both; timer_cb skips on PREEMPT_RT, as before. Without
patch 1, private_stack_tail_call fails: the program with a private
stack goes into the prog array. On PREEMPT_RT without patch 2, the nine
subtests of marked programs fail: B runs after A instead of being
dropped. Without PREEMPT_RT, test_progs shows no new failures.

[1] https://lore.kernel.org/bpf/DN9PF7JVRP7H.262PMB9O02SBG@gmail.com/

---
Mike Bazov (4):
      bpf: Refuse struct_ops programs with a private stack in prog arrays
      bpf: Keep a per-CPU counter for marked programs on PREEMPT_RT
      selftests/bpf: Test private-stack struct_ops progs in prog arrays
      selftests/bpf: Expect marked programs to drop B on PREEMPT_RT

 include/linux/bpf.h                                | 33 +++++++++++----
 include/linux/filter.h                             |  7 ----
 kernel/bpf/arraymap.c                              |  1 +
 .../bpf/prog_tests/struct_ops_private_stack.c      | 34 +++++++++++++++
 .../selftests/bpf/prog_tests/trampoline_preempt.c  | 35 +++++++++++++---
 .../bpf/progs/struct_ops_private_stack_tail_call.c | 49 ++++++++++++++++++++++
 6 files changed, 138 insertions(+), 21 deletions(-)
---
base-commit: 23eac23279b6c114ad70a176b6dd546e88a981f8
change-id: 20261202-followup-rt-stops-02dc25401b3d

Best regards,
-- 
Mike Bazov <mike.bazov@gmail.com>



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

end of thread, other threads:[~2026-12-02 13:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-02 13:15 [PATCH bpf-next 0/4] bpf: Per-task recursion follow-ups for struct_ops and PREEMPT_RT Mike Bazov via B4 Relay
2026-12-02 13:15 ` [PATCH bpf-next 1/4] bpf: Refuse struct_ops programs with a private stack in prog arrays Mike Bazov via B4 Relay
2026-12-02 13:15 ` [PATCH bpf-next 2/4] bpf: Keep a per-CPU counter for marked programs on PREEMPT_RT Mike Bazov via B4 Relay
2026-12-02 13:59   ` bot+bpf-ci
2026-12-02 13:15 ` [PATCH bpf-next 3/4] selftests/bpf: Test private-stack struct_ops progs in prog arrays Mike Bazov via B4 Relay
2026-12-02 13:15 ` [PATCH bpf-next 4/4] selftests/bpf: Expect marked programs to drop B on PREEMPT_RT Mike Bazov via B4 Relay

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

all inboxes | Powered by JetHome®