public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/8] bpf: Enhance __bpf_prog_map_compatible()
@ 2026-02-24 15:40 Leon Hwang
  2026-02-24 15:40 ` [PATCH bpf-next 1/8] bpf: Add fsession to verbose log in check_get_func_ip() Leon Hwang
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Leon Hwang @ 2026-02-24 15:40 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Shuah Khan, Feng Yang, Leon Hwang, Menglong Dong, Puranjay Mohan,
	Björn Töpel, Pu Lehui, linux-kernel, linux-kselftest,
	netdev, kernel-patches-bot

Following discussion in the "bpf: tail calls in sleepable programs" [1],
this series extends __bpf_prog_map_compatible() with additional per-program
compatibility checks.

The series validates these attributes:

* kprobe_write_ctx: for uprobe programs that can update pt_regs.
* call_get_func_ip: for tracing programs using bpf_get_func_ip().
* call_session_cookie: for fsession programs using bpf_session_cookie().
* call_session_is_return: for fsession programs using bpf_session_is_return().

For each attribute, prog_array compatibility is one-way:
programs without the requirement are rejected when tail-calling into
programs that require it.

This keeps tail-call runtime assumptions consistent. For example,
call_get_func_ip programs rely on func_ip metadata prepared on trampoline
stack; tail-calling from a !call_get_func_ip program into such a callee can
produce invalid func_ip values. The same class of issue applies to
call_session_cookie and call_session_is_return.

Links:
[1] https://lore.kernel.org/bpf/20260130081208.1130204-1-jolsa@kernel.org/

Leon Hwang (8):
  bpf: Add fsession to verbose log in check_get_func_ip()
  bpf: Disallow !kprobe_write_ctx progs tail-calling kprobe_write_ctx
    progs
  bpf: Disallow !call_get_func_ip progs tail-calling call_get_func_ip
    progs
  bpf: Disallow !call_session_cookie progs tail-calling
    call_session_cookie progs
  bpf: Disallow !call_session_is_return progs tail-calling
    call_session_is_return progs
  selftests/bpf: Add a test to verify kprobe_write_ctx compatibility
    enforcement
  selftests/bpf: Add a test to verify call_get_func_ip compatibility
    enforcement
  selftests/bpf: Add a test to verify session-kfunc compatibility
    enforcement

 include/linux/bpf.h                           | 11 +++--
 kernel/bpf/core.c                             | 15 ++++++
 kernel/bpf/verifier.c                         |  4 +-
 .../selftests/bpf/prog_tests/attach_probe.c   | 44 +++++++++++++++++
 .../selftests/bpf/prog_tests/fsession_test.c  | 47 +++++++++++++++++++
 .../bpf/prog_tests/get_func_ip_test.c         | 46 ++++++++++++++++++
 .../selftests/bpf/progs/fsession_test.c       |  6 +++
 .../selftests/bpf/progs/get_func_ip_test.c    |  6 +++
 .../selftests/bpf/progs/kprobe_write_ctx.c    |  6 +++
 9 files changed, 181 insertions(+), 4 deletions(-)

-- 
2.52.0


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

end of thread, other threads:[~2026-02-25 15:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-24 15:40 [PATCH bpf-next 0/8] bpf: Enhance __bpf_prog_map_compatible() Leon Hwang
2026-02-24 15:40 ` [PATCH bpf-next 1/8] bpf: Add fsession to verbose log in check_get_func_ip() Leon Hwang
2026-02-24 15:40 ` [PATCH bpf-next 2/8] bpf: Disallow !kprobe_write_ctx progs tail-calling kprobe_write_ctx progs Leon Hwang
2026-02-24 16:22   ` bot+bpf-ci
2026-02-24 16:57   ` Alexei Starovoitov
2026-02-25 15:15     ` Leon Hwang
2026-02-24 15:40 ` [PATCH bpf-next 3/8] bpf: Disallow !call_get_func_ip progs tail-calling call_get_func_ip progs Leon Hwang
2026-02-24 16:35   ` bot+bpf-ci
2026-02-24 15:40 ` [PATCH bpf-next 4/8] bpf: Disallow !call_session_cookie progs tail-calling call_session_cookie progs Leon Hwang
2026-02-24 15:40 ` [PATCH bpf-next 5/8] bpf: Disallow !call_session_is_return progs tail-calling call_session_is_return progs Leon Hwang
2026-02-24 15:40 ` [PATCH bpf-next 6/8] selftests/bpf: Add a test to verify kprobe_write_ctx compatibility enforcement Leon Hwang
2026-02-24 15:40 ` [PATCH bpf-next 7/8] selftests/bpf: Add a test to verify call_get_func_ip " Leon Hwang
2026-02-24 15:40 ` [PATCH bpf-next 8/8] selftests/bpf: Add a test to verify session-kfunc " Leon Hwang

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