From: Mike Bazov via B4 Relay <devnull+mike.bazov.gmail.com@kernel.org>
To: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>
Cc: Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Emil Tsalapatis <emil@etsalapatis.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
JP Kobryn <jp.kobryn@linux.dev>,
linux-trace-kernel@vger.kernel.org,
linux-kernel@vger.kernel.org, Mike Bazov <mike.bazov@gmail.com>
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 [thread overview]
Message-ID: <20261202-followup-rt-stops-v1-0-22562be9ddb0@gmail.com> (raw)
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>
next reply other threads:[~2026-12-02 13:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 13:15 Mike Bazov via B4 Relay [this message]
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
2026-12-02 20:00 ` [PATCH bpf-next 0/4] bpf: Per-task recursion follow-ups for struct_ops and PREEMPT_RT patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202-followup-rt-stops-v1-0-22562be9ddb0@gmail.com \
--to=devnull+mike.bazov.gmail.com@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=jp.kobryn@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mathieu.desnoyers@efficios.com \
--cc=memxor@gmail.com \
--cc=mhiramat@kernel.org \
--cc=mike.bazov@gmail.com \
--cc=rostedt@goodmis.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox