[PATCH bpf-next v3 1/3] bpf: Don't WARN when bpf_perf_event_output() nests too deep
From: Mike Bazov via B4 Relay
Date: Fri Nov 20 2026 - 05:59:53 EST
From: Mike Bazov <mike.bazov@xxxxxxxxx>
bpf_perf_event_output() takes one of three per-CPU perf_sample_data
slots per nesting level, and fails with -EBUSY and a WARN_ON_ONCE() when
it is entered a fourth time on a CPU. Programs get there without any
bug: a kprobe program calls it, and fentry programs on
perf_event_output() call it again from inside. Each program's own
recursion check lets it in once, so three of them reach the fourth
level. With panic_on_warn, that takes the machine down.
Keep the -EBUSY and drop the warning, as commit 3880cdbed1c4 ("bpf: Fix
WARN() in get_bpf_raw_tp_regs") did for the raw tracepoint regs slots.
Signed-off-by: Mike Bazov <mike.bazov@xxxxxxxxx>
---
kernel/trace/bpf_trace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index b4ff9d4e8..8910d5d05 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -702,7 +702,7 @@ BPF_CALL_5(bpf_perf_event_output, struct pt_regs *, regs, struct bpf_map *, map,
sds = this_cpu_ptr(&bpf_trace_sds);
nest_level = this_cpu_inc_return(bpf_trace_nest_level);
- if (WARN_ON_ONCE(nest_level > ARRAY_SIZE(sds->sds))) {
+ if (nest_level > ARRAY_SIZE(sds->sds)) {
err = -EBUSY;
goto out;
}
--
2.43.0