libbpf: Skip BPF token preparation for gen_loader
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | libbpf: Skip BPF token preparation when generating loadertools/ | +3 | 0 replies | |
| 2/2 | selftests/bpf: Verify gen_loader skips BPF token preparationtools/ | +82 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH bpf 0/2] libbpf: Skip BPF token preparation for gen_loader
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
Signature · 1 line
2.56.1.750.gf70dc682cf-goog