From: bot+bpf-ci@kernel.org
To: mike.bazov@gmail.com,song@kernel.org,jolsa@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
Cc: bpf@vger.kernel.org,linux-kernel@vger.kernel.org,linux-trace-kernel@vger.kernel.org,mike.bazov@gmail.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v2] bpf: Use an on-stack pt_regs in the raw tracepoint helpers
Date: Thu, 19 Nov 2026 11:14:51 +0000 (UTC) [thread overview]
Message-ID: <77d978d7f9343e907651b4d4d81ec1c1405dce42f75e33b169f729f208029fcc@mail.kernel.org> (raw)
In-Reply-To: <20261119-bpf-raw-tp-regs-preempt-v2-1-e1e1b90857d6@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2947 bytes --]
> 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?
---
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
prev parent reply other threads:[~2026-11-19 11:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 10:37 Mike Bazov via B4 Relay
2026-11-19 11:14 ` bot+bpf-ci [this message]
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=77d978d7f9343e907651b4d4d81ec1c1405dce42f75e33b169f729f208029fcc@mail.kernel.org \
--to=bot+bpf-ci@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=jolsa@kernel.org \
--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 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®