From: Mike Bazov Subject: [PATCH bpf-next 0/4] bpf: Per-task recursion follow-ups for struct_ops and PREEMPT_RT Date: Wed, 02 Dec 2026 15:15:12 +0200 Message-Id: <20261202-followup-rt-stops-v1-0-22562be9ddb0@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAOAZEGsC/z2MSwrDMAxErxK0rsB2P4tepXThj5wYgm0kNw2E3 L1OF9kMvBnmbSDEiQSewwZMS5JUcgd9GcBPNo+EKXQGo8xD98BY5rl8PxW5obRSBZUJ3txvSrt rgP6rTDGtf+cLXI2YaW3w7ouzQujYZj8dzlN19LDvP33Gd5WNAAAA To: bpf@vger.kernel.org, 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@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Bazov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796217344; l=2508; i=mike.bazov@gmail.com; s=gmail-20261116; h=from:subject:message-id; bh=LYxjXKso8vz5vL4N3stbN0Xb7QeLkysGdklOIHIpvv0=; b=oLJELre06w+oLqZu4D8j2FtJpAHMt1oHW2jOTRb5XSNCaCyz2RvFrw/tseGUfrFnTLtm+yuJL 6M0+dR+VKG/CIKmJqawtrg70NYwBoFFDjiZ5bENlXQ9BjE0YodTVq10 X-Developer-Key: i=mike.bazov@gmail.com; a=ed25519; pk=Rr9fagn0pNA+bs8tgc6DXZpRAhl/maU6BeqkttIR7DA= X-Endpoint-Received: by B4 Relay for mike.bazov@gmail.com/gmail-20261116 with auth_id=1544 List-Id: B4 Relay Submissions 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