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 1/4] bpf: Refuse struct_ops programs with a private stack in prog arrays
Date: Wed, 02 Dec 2026 15:15:13 +0200 [thread overview]
Message-ID: <20261202-followup-rt-stops-v1-1-22562be9ddb0@gmail.com> (raw)
In-Reply-To: <20261202-followup-rt-stops-v1-0-22562be9ddb0@gmail.com>
From: Mike Bazov <mike.bazov@gmail.com>
A struct_ops program gets a private stack only if the subsystem requests
one, and then its trampoline runs it with a recursion check, so two runs
of it on one CPU never share the stack. A tail call enters the program
past the trampoline. The caller is a struct_ops program of the same op
and has no private stack, since a program with a tail call gets none,
so it has no recursion check: two tasks on one CPU can be inside it and
both tail-call into the target, which then runs twice on the same
private stack.
Refuse a struct_ops program that uses a private stack as a prog array
element.
Fixes: 5bd36da1e37e ("bpf: Support private stack for struct_ops progs")
Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Mike Bazov <mike.bazov@gmail.com>
---
kernel/bpf/arraymap.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index 508706d0c36..564a736275a 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -1044,6 +1044,7 @@ static void *prog_fd_array_get_ptr(struct bpf_map *map,
return prog;
if (prog->type == BPF_PROG_TYPE_EXT ||
+ (prog->type == BPF_PROG_TYPE_STRUCT_OPS && prog->aux->jits_use_priv_stack) ||
!bpf_prog_map_compatible(map, prog)) {
bpf_prog_put(prog);
return ERR_PTR(-EINVAL);
--
2.43.0
next prev parent reply other threads:[~2026-12-02 13:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Mike Bazov via B4 Relay [this message]
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
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-1-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
all inboxes | Powered by JetHome®