All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: <mikeba@sentinelone.com>, <bpf@vger.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>
Subject: Re: [PATCH bpf-next v2 2/5] bpf: Check program recursion per task via bpf_ctx
Date: Thu, 12 Nov 2026 01:04:30 +0000	[thread overview]
Message-ID: <DMSTTWR4MAET.1VEV3R66S7ZFY@gmail.com> (raw)
In-Reply-To: <20261111-bpf-preempt-v2-r2-v2-2-9d8f6b952ad2@sentinelone.com>

On Wed, Nov 11, 2026 at 11:39 AM Mike Bazov via B4 Relay <devnull+mikeba.sentinelone.com@kernel.org> wrote:
> As a result, the same program can now run in two tasks at once on one
> CPU. Programs that use a per-CPU map as scratch space across helper
> calls may see another run's data, where the run was dropped before.

The kernel has such scratch space too: bpf_raw_tp_regs.
bpf_get_stack(), bpf_get_stackid() and bpf_perf_event_output() of fentry,
raw_tp and tp_btf progs take a slot of it with get_bpf_raw_tp_regs().
It doesn't disable preemption. Three tasks on one cpu:

  task A              task B              task C
  level 1, regs[0]
  <preempted>
                      level 2, regs[1]
                      <preempted>
  put: level 1
                                          level 2, regs[1]
                      uses the regs of C

B sends a sample or a stack trace with the regs of C.
This is an existing bug. Today it takes two or more progs.
With this patch A, B and C can be in one prog.
Doesn't hold the series, but I had to mention.

> Fixes: ca06f55b9002 ("bpf: Add per-program recursion prevention mechanism")
> Fixes: a46023d5616e ("tracing: Guard __DECLARE_TRACE() use of __DO_TRACE_CALL() with SRCU-fast")
> Fixes: 439ebd5b5708 ("bpf: Add sleepable support for raw tracepoint programs")

I don't think we will be sending them to stable soon.
This is a big behavior change.
Backports only after next merge window.

  reply	other threads:[~2026-11-12  1:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11 19:39 [PATCH bpf-next v2 0/5] bpf: Check recursion per task for preemptible programs Mike Bazov via B4 Relay
2026-11-11 19:39 ` Mike Bazov
2026-11-11 19:39 ` [PATCH bpf-next v2 1/5] bpf: Avoid per-CPU private stack in preemptible tracing progs Mike Bazov via B4 Relay
2026-11-11 19:39   ` Mike Bazov
2026-11-11 20:10   ` sashiko-bot
2026-11-11 21:07   ` bot+bpf-ci
2026-11-11 19:39 ` [PATCH bpf-next v2 2/5] bpf: Check program recursion per task via bpf_ctx Mike Bazov via B4 Relay
2026-11-11 19:39   ` Mike Bazov
2026-11-12  1:04   ` Alexei Starovoitov [this message]
2026-11-12 19:30     ` [EXT.MSG] " Mike Bazov
2026-11-11 19:39 ` [PATCH bpf-next v2 3/5] bpf: Check recursion per task for programs on syscall tracepoints Mike Bazov via B4 Relay
2026-11-11 19:39   ` Mike Bazov
2026-11-11 19:39 ` [PATCH bpf-next v2 4/5] selftests/bpf: Add trampoline and raw_tp preemption recursion test Mike Bazov via B4 Relay
2026-11-11 19:39   ` Mike Bazov
2026-11-11 20:08   ` sashiko-bot
2026-11-11 19:39 ` [PATCH bpf-next v2 5/5] selftests/bpf: Test syscall tracepoint programs under preemption Mike Bazov via B4 Relay
2026-11-11 19:39   ` Mike Bazov
2026-11-12  1:18 ` [PATCH bpf-next v2 0/5] bpf: Check recursion per task for preemptible programs Alexei Starovoitov
2026-11-12 19:24   ` [EXT.MSG] " Mike Bazov

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=DMSTTWR4MAET.1VEV3R66S7ZFY@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii@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=mikeba@sentinelone.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.