Re: [PATCH bpf-next v2] bpf: Use an on-stack pt_regs in the raw tracepoint helpers
From: bot+bpf-ci
Date: Thu Nov 19 2026 - 06:15:04 EST
> 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