BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v2 0/2] Reject callback subprogs invoke tailcall
@ 2026-07-14  2:44 Pu Lehui
  2026-07-14  2:44 ` [PATCH bpf-next v2 1/2] bpf: " Pu Lehui
  2026-07-14  2:44 ` [PATCH bpf-next v2 2/2] selftests/bpf: Add testcase for callback with tailcall Pu Lehui
  0 siblings, 2 replies; 6+ messages in thread
From: Pu Lehui @ 2026-07-14  2:44 UTC (permalink / raw)
  To: bpf, linux-kernel, Eduard Zingerman, Björn Töpel,
	Daniel Borkmann
  Cc: Alexei Starovoitov, Andrii Nakryiko, Kumar Kartikeya Dwivedi,
	Yonghong Song, Martin KaFai Lau, Song Liu, Jiri Olsa,
	Emil Tsalapatis, Pu Lehui, Pu Lehui

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@huaweicloud.com

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-07-14 13:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-14  2:44 [PATCH bpf-next v2 0/2] Reject callback subprogs invoke tailcall Pu Lehui
2026-07-14  2:44 ` [PATCH bpf-next v2 1/2] bpf: " Pu Lehui
2026-07-14  2:56   ` sashiko-bot
2026-07-14 13:47     ` Björn Töpel
2026-07-14  2:44 ` [PATCH bpf-next v2 2/2] selftests/bpf: Add testcase for callback with tailcall Pu Lehui
2026-07-14  2:53   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox