All of lore.kernel.org
 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 2/2] bpftool: Reject non-autoload programs for light skeletons
Date: Fri, 04 Sep 2026 03:24:36 +0000	[thread overview]
Message-ID: <20260904032437.24BDA1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260904031912.2133476-2-tweek@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Direct return on the error path for non-autoload programs leaks the file descriptor, memory mapping, and BPF object.
--

commit 2f23ddc68c8f556d1272e5244820c6008be97512
Author: Thiébaud Weksteen <tweek@google.com>

bpftool: Reject non-autoload programs for light skeletons
    
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. This commit explicitly rejects
non-autoloaded programs when use_loader is true with an error message to
prevent generating broken light skeleton headers.

> diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
> index a50540ef6521c..1583150241c88 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;

[Severity: Low]
Does this code leak the file descriptor, memory mapping, and BPF object?

Since this returns directly, it bypasses the established resource cleanup block
(the out: and out_obj: labels) at the end of do_skeleton(), which would
normally call bpf_object__close(obj), munmap(obj_data, mmap_sz), and close(fd).

Could this set err = -1 and use goto out; instead?

> +		}
>  	}
>  
>  	get_header_guard(header_guard, obj_name, "SKEL_H");

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

  reply	other threads:[~2026-09-04  3:24 UTC|newest]

Thread overview: 10+ 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 ` [PATCH bpf-next 2/2] bpftool: Reject non-autoload programs for light skeletons Thiébaud Weksteen
2026-09-04  3:24   ` sashiko-bot [this message]
2026-09-04  4:13   ` bot+bpf-ci
2026-09-07 15:24   ` Quentin Monnet
2026-09-08  4:57     ` Thiébaud Weksteen
2026-09-04  6:07 ` [PATCH bpf-next 1/2] selftests/bpf: Move verifier failure tests out of test_global_percpu_data Leon Hwang
2026-09-07  5:46   ` Thiébaud Weksteen
2026-09-07 15:24     ` Leon Hwang
2026-09-08  1:04       ` 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=20260904032437.24BDA1F00A3D@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.