From: "Thiébaud Weksteen" <tweek@google.com>
To: "Quentin Monnet" <qmo@kernel.org>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Shuah Khan" <shuah@kernel.org>,
"Leon Hwang" <leon.hwang@linux.dev>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Thiébaud Weksteen" <tweek@google.com>
Cc: Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
Sid Nayyar <sidnayyar@google.com>,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: [PATCH bpf-next 2/2] bpftool: Reject non-autoload programs for light skeletons
Date: Fri, 4 Sep 2026 13:19:12 +1000 [thread overview]
Message-ID: <20260904031912.2133476-2-tweek@google.com> (raw)
In-Reply-To: <20260904031912.2133476-1-tweek@google.com>
When generating a light skeleton (bpftool gen skeleton -L), there is no
libbpf runtime object or bpf_program__set_autoload() API available to
enable/disable the autoloading of programs. If a BPF program in the
object has autoload disabled (e.g. via SEC("?...")), bpf_object__load()
silently skips loading it. bpftool still generates struct bpf_prog_desc
fields and attach functions in the light skeleton header, leaving
skel->progs.<name>.prog_fd uninitialized (0).
Explicitly reject non-autoloaded programs when use_loader is true with
an error message, preventing the generation of broken light skeleton
headers.
Signed-off-by: Thiébaud Weksteen <tweek@google.com>
---
tools/bpf/bpftool/gen.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
index a50540ef6521..1583150241c8 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -1340,6 +1340,12 @@ static int do_skeleton(int argc, char **argv)
}
bpf_object__for_each_program(prog, obj) {
prog_cnt++;
+
+ if (use_loader && !bpf_program__autoload(prog)) {
+ p_err("program '%s' is marked as non-autoload, which is not supported for light skeletons",
+ bpf_program__name(prog));
+ return -1;
+ }
}
get_header_guard(header_guard, obj_name, "SKEL_H");
--
2.55.0.979.g7e5102b832-goog
next prev parent reply other threads:[~2026-09-04 3:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 3:19 [PATCH bpf-next 1/2] selftests/bpf: Move verifier failure tests out of test_global_percpu_data Thiébaud Weksteen
2026-09-04 3:19 ` Thiébaud Weksteen [this message]
2026-09-04 4:13 ` [PATCH bpf-next 2/2] bpftool: Reject non-autoload programs for light skeletons bot+bpf-ci
2026-09-04 6:07 ` [PATCH bpf-next 1/2] selftests/bpf: Move verifier failure tests out of test_global_percpu_data Leon Hwang
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=20260904031912.2133476-2-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=leon.hwang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=qmo@kernel.org \
--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
all inboxes | Powered by JetHome®