[PATCH bpf-next v2 0/2] Reject callback subprogs invoke tailcall

From: Pu Lehui

Date: Mon Jul 13 2026 - 22:42:17 EST


Some JIT compilers, such as x86_64, rely on a register to pass the TCC.
When subprograms of synchronous callback invoke tailcall, C helpers
invoking bpf callback clobber this register, and the corrupted TCC may
bypass the TCC limit, leading to infinite tailcall.

Fix this by rejecting tailcall inside all subprogs of sync callback.
This also cleanly consolidates the existing async and exception callback
checks into a single unified `is_cb` check.

v2:
- remove redantant testcase.
- Add ACK tag by Eduard.

v1: https://lore.kernel.org/bpf/20260711104727.4023420-1-pulehui@xxxxxxxxxxxxxxx

Pu Lehui (2):
bpf: Reject callback subprogs invoke tailcall
selftests/bpf: Add testcase for callback with tailcall

kernel/bpf/verifier.c | 8 +--
.../selftests/bpf/prog_tests/tailcalls.c | 7 +++
.../bpf/progs/tailcall_bpf2bpf_callback.c | 62 +++++++++++++++++++
3 files changed, 71 insertions(+), 6 deletions(-)
create mode 100644 tools/testing/selftests/bpf/progs/tailcall_bpf2bpf_callback.c

--
2.34.1