From: Jiri Olsa <olsajiri@gmail.com>
To: bot+bpf-ci@kernel.org
Cc: mike.bazov@gmail.com, song@kernel.org, ihor.solodrai@linux.dev,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
eddyz87@gmail.com, memxor@gmail.com, martin.lau@linux.dev,
yonghong.song@linux.dev, emil@etsalapatis.com,
kpsingh@kernel.org, matt@bobrowski.net, rostedt@goodmis.org,
mhiramat@kernel.org, mathieu.desnoyers@efficios.com,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-trace-kernel@vger.kernel.org, martin.lau@kernel.org,
mason@kernel.org
Subject: Re: [PATCH bpf-next v2] bpf: Use an on-stack pt_regs in the raw tracepoint helpers
Date: Thu, 19 Nov 2026 20:28:37 +0100 [thread overview]
Message-ID: <av9N5RqhdRhW1fVh@krava> (raw)
In-Reply-To: <77d978d7f9343e907651b4d4d81ec1c1405dce42f75e33b169f729f208029fcc@mail.kernel.org>
On Thu, Nov 19, 2026 at 11:14:51AM +0000, bot+bpf-ci@kernel.org wrote:
> > bpf: Use an on-stack pt_regs in the raw tracepoint helpers
>
> TL;DR: Without the per-CPU slots, nested raw_tp/fentry programs may hit the
> WARN_ON_ONCE in bpf_perf_event_output() (panic with panic_on_warn); the commit
> message's claim of no more -EBUSY also looks wrong.
>
> > diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> > --- a/kernel/trace/bpf_trace.c
> > +++ b/kernel/trace/bpf_trace.c
>
> [ ... ]
>
> > BPF_CALL_5(bpf_perf_event_output_raw_tp, struct bpf_raw_tracepoint_args *, args,
> > struct bpf_map *, map, u64, flags, void *, data, u64, size)
> > {
> > - struct pt_regs *regs = get_bpf_raw_tp_regs();
> > - int ret;
> > -
> > - if (IS_ERR(regs))
> > - return PTR_ERR(regs);
> > -
> > - perf_fetch_caller_regs(regs);
> > - ret = ____bpf_perf_event_output(regs, map, flags, data, size);
> > + struct pt_regs regs = {};
> >
> > - put_bpf_raw_tp_regs();
> > - return ret;
> > + perf_fetch_caller_regs(®s);
> > + return ____bpf_perf_event_output(®s, map, flags, data, size);
> > }
>
> Can this reach the WARN_ON_ONCE() in bpf_perf_event_output() using only
> raw_tp and tracing programs?
>
> bpf_perf_event_output() still has a three-level limit:
>
> nest_level = this_cpu_inc_return(bpf_trace_nest_level);
>
> if (WARN_ON_ONCE(nest_level > ARRAY_SIZE(sds->sds))) {
> err = -EBUSY;
> goto out;
> }
>
> Before this patch, every raw_tp/tracing caller first took a
> bpf_raw_tp_nest_level slot, so a fourth nested caller got a silent -EBUSY
> from get_bpf_raw_tp_regs(). That function's WARN_ON_ONCE was removed by
> commit 3880cdbed1c4 ("bpf: Fix WARN() in get_bpf_raw_tp_regs") after a
> syzbot report of this kind of nesting. The WARN above could only fire if a
> kprobe, tracepoint or perf_event program was also in the chain.
>
> With the slots gone, a chain of only raw_tp/tracing programs can get there.
> For example, a raw_tp program A calls bpf_perf_event_output() (nest 1),
> and its __bpf_perf_event_output() calls perf_event_output(). Fentry
> programs B, C and D attached to perf_event_output() also call
> bpf_perf_event_output(), and each is let through once by its own
> prog->active check, so they run at nest 2, 3 and 4. At D the WARN_ON_ONCE
> fires, and with panic_on_warn the kernel panics. The same depth is
> reachable across task, softirq, hardirq and NMI context.
>
> This also seems to contradict the commit message:
>
> > the helpers no longer fail with -EBUSY when nested more than three deep
>
> For bpf_perf_event_output() the three-level limit remains, coming from
> bpf_trace_sds and bpf_trace_nest_level.
>
> Should the WARN_ON_ONCE in bpf_perf_event_output() be dropped, as
> 3880cdbed1c4 did for get_bpf_raw_tp_regs(), and should the commit message
> say that bpf_perf_event_output() keeps its three-level limit?
+1 we can now nest more than 3 times, hitting that limit shouldn't warn
jirka
>
>
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
>
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/44508926690
next prev parent reply other threads:[~2026-11-19 19:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 10:37 [PATCH bpf-next v2] bpf: Use an on-stack pt_regs in the raw tracepoint helpers Mike Bazov
2026-11-19 10:37 ` Mike Bazov via B4 Relay
2026-11-19 11:14 ` bot+bpf-ci
2026-11-19 19:28 ` Jiri Olsa [this message]
2026-11-20 1:08 ` Alexei Starovoitov
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=av9N5RqhdRhW1fVh@krava \
--to=olsajiri@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@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=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=martin.lau@linux.dev \
--cc=mason@kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=matt@bobrowski.net \
--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 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.