BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Thiébaud Weksteen" <tweek@google.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 1/2] bpftool: Skip non-autoload programs when generating light skeletons
Date: Tue, 08 Sep 2026 07:13:44 +0000	[thread overview]
Message-ID: <20260908071345.6A7001F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908065529.901593-1-tweek@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Low] Generated light skeleton header fails to compile for objects with only non-autoload programs due to a missing `links` struct.
--

commit 476d6487301750ab1f480a6655fe84b67748df84
Author: Thiébaud Weksteen <tweek@google.com>

bpftool: Skip non-autoload programs when generating light skeletons

This commit modifies bpftool to skip non-autoload programs when generating
light skeletons (-L). This prevents the generated loader program from recording
file descriptors into incorrect skeleton struct fields.

> diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
> index a50540ef6521c..0fcfe20ff5158 100644
> --- a/tools/bpf/bpftool/gen.c
> +++ b/tools/bpf/bpftool/gen.c
[ ... ]
> @@ -1415,6 +1428,8 @@ static int do_skeleton(int argc, char **argv)
>  	if (prog_cnt + attach_map_cnt) {
>  		printf("\tstruct {\n");
>  		bpf_object__for_each_program(prog, obj) {
> +			if (use_loader && !bpf_program__autoload(prog))
> +				continue;
>  			if (use_loader)
>  				printf("\t\tint %s_fd;\n",
>  				       bpf_program__name(prog));

[Severity: Low]
This isn't a bug introduced by this patch, but by skipping non-autoloaded
programs, this patch can reduce prog_cnt to 0 for objects where all programs
are marked as non-autoload.

If prog_cnt + attach_map_cnt evaluates to 0, the links struct is omitted
from the generated skeleton. However, gen_trace() unconditionally generates
code that relies on the links member:

tools/bpf/bpftool/gen.c:gen_trace() {
    ...
	codegen("\
		\n\
		...
			skel->ctx.sz = (char *)&skel->links - (char *)skel; \n\
		...
    ...
}

Can this cause the generated light skeleton header to fail to compile for
objects with only non-autoload programs? Does gen_trace() need to be updated
to handle the case where the links struct is missing?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260908065529.901593-1-tweek@google.com?part=1

  parent reply	other threads:[~2026-09-08  7:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08  6:55 [PATCH bpf-next 1/2] bpftool: Skip non-autoload programs when generating light skeletons Thiébaud Weksteen
2026-09-08  6:55 ` [PATCH bpf-next 2/2] selftests/bpf: Verify program FD after non-autoload programs in lskel Thiébaud Weksteen
2026-09-08 15:46   ` bot+bpf-ci
2026-09-08  7:13 ` sashiko-bot [this message]
2026-09-08 16:01 ` [PATCH bpf-next 1/2] bpftool: Skip non-autoload programs when generating light skeletons bot+bpf-ci
2026-09-08 23:48   ` Quentin Monnet

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=20260908071345.6A7001F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tweek@google.com \
    /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