From: "Thiébaud Weksteen" <tweek@google.com>
To: Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Shuah Khan <shuah@kernel.org>
Cc: "Thiébaud Weksteen" <tweek@google.com>,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Ihor Solodrai" <ihor.solodrai@linux.dev>,
"Sid Nayyar" <sidnayyar@google.com>
Subject: [PATCH bpf 0/2] libbpf: Skip BPF token preparation for gen_loader
Date: Mon, 23 Nov 2026 15:57:28 +1100 [thread overview]
Message-ID: <20261123045730.1960346-1-tweek@google.com> (raw)
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
next reply other threads:[~2026-11-23 4:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 4:57 Thiébaud Weksteen [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123045730.1960346-1-tweek@google.com \
--to=tweek@google.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=shuah@kernel.org \
--cc=sidnayyar@google.com \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox