Re: [EXT.MSG] Re: [PATCH RFC bpf-next 0/2] bpf: Do not let preemption cause false recursion drops in trampoline progs
From: Mike Bazov
Date: Tue Nov 10 2026 - 15:47:33 EST
On Mon, Nov 9, 2026 at 4:12 PM JP Kobryn wrote:
> Before moving away from an in-kernel solution, can we consider the
> direction this patch below takes?
I haven't proposed moving away from an in-kernel solution. Your patch
is the same design I proposed earlier in this thread ("This is what I
have in mind for v2") with Andrii's bpf_ctx suggestion folded in, and
it's what I've been putting together for v2 (unless someone comes up
with a better direction), which is nearly ready to
post, so let's avoid duplicating the work.
beyond trampoline progs, v2 also covers raw_tp, tp_btf, syscall
tracepoints, and BPF_PROG_TEST_RUN, and disables the per-CPU private
stack for preemptible tracing progs since two tasks can now run the
same prog concurrently on one CPU.
a couple of notes on your patch:
- Passing prog to bpf_set_run_ctx() churns all callers that don't do
recursion checks, and doesn't fit bpf_prog_run_array_sleepable(),
which reuses one bpf_run_ctx across all progs in the array. In v2,
bpf_set_run_ctx() keeps its signature and initializes prog to NULL,
and bpf_prog_enter_recur_ctx() sets it after the walk succeeds.
- bpf_io_uring_submit_sqes() calls bpf_set_run_ctx(NULL), so
dereferencing new_ctx unconditionally will NULL-deref there.
- Cross-task synchronization isn't needed: a task only ever walks its
own current->bpf_ctx chain (and any IRQ/NMI on top of it runs on the
same CPU and walks the same chain), so compiler barriers around
linking and unlinking the frame are sufficient.
I'll Cc you on v2 once I post it (probably by tomorrow evening UTC).
testing and review there would be appreciated.
Mike