BPF List
 help / color / mirror / Atom feed
* [PATCH bpf 0/2] libbpf: Skip BPF token preparation for gen_loader
@ 2026-11-23  4:57 Thiébaud Weksteen
  2026-11-23  4:57 ` [PATCH bpf 1/2] libbpf: Skip BPF token preparation when generating loader Thiébaud Weksteen
  2026-11-23  4:57 ` [PATCH bpf 2/2] selftests/bpf: Verify gen_loader skips BPF token preparation Thiébaud Weksteen
  0 siblings, 2 replies; 3+ messages in thread
From: Thiébaud Weksteen @ 2026-11-23  4:57 UTC (permalink / raw)
  To: Andrii Nakryiko, Eduard Zingerman, Alexei Starovoitov,
	Daniel Borkmann, Kumar Kartikeya Dwivedi, Shuah Khan
  Cc: Thiébaud Weksteen, bpf, linux-kselftest, Martin KaFai Lau,
	Song Liu, Yonghong Song, Jiri Olsa, Emil Tsalapatis,
	Ihor Solodrai, Sid Nayyar

When generating a loader program offline (obj->gen_loader), libbpf emits
loader instructions rather than issuing BPF syscalls on the host. While
other host-interaction steps in bpf_object_prepare() already skip
execution under obj->gen_loader, bpf_object_prepare_token() does not.

This causes offline loader generation (such as bpftool gen skeleton -L)
to probe /sys/fs/bpf and honor LIBBPF_BPF_TOKEN_PATH. If the build host
has a token-delegated bpffs mounted, libbpf acquires a token FD and ORs
BPF_F_TOKEN_FD into map_flags and prog_flags without gen_loader
serializing any token_fd, producing a broken loader blob.

Patch 1 skips bpf_object_prepare_token() when obj->gen_loader is set.
Patch 2 adds a token/obj_gen_loader_no_token selftest covering implicit
/sys/fs/bpf delegation, explicit bpf_token_path, and an invalid
LIBBPF_BPF_TOKEN_PATH.

Thiébaud Weksteen (2):
  libbpf: Skip BPF token preparation when generating loader
  selftests/bpf: Verify gen_loader skips BPF token preparation

 tools/lib/bpf/libbpf.c                        |  3 +
 .../testing/selftests/bpf/prog_tests/token.c  | 82 +++++++++++++++++++
 2 files changed, 85 insertions(+)


base-commit: 84afebd853437e44cb71f718be11d90e4c1a59dd
-- 
2.56.1.750.gf70dc682cf-goog


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

end of thread, other threads:[~2026-11-23  4:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23  4:57 [PATCH bpf 0/2] libbpf: Skip BPF token preparation for gen_loader Thiébaud Weksteen
2026-11-23  4:57 ` [PATCH bpf 1/2] libbpf: Skip BPF token preparation when generating loader Thiébaud Weksteen
2026-11-23  4:57 ` [PATCH bpf 2/2] selftests/bpf: Verify gen_loader skips BPF token preparation Thiébaud Weksteen

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