All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 1/4] libbpf, bpftool: Keep places of programs and maps in light skeletons
Date: Sat, 05 Dec 2026 01:25:29 +0000	[thread overview]
Message-ID: <sashiko-outbox-250893@kernel.org> (raw)
In-Reply-To: <20261205010519.2565529-2-alexei.starovoitov@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] bpftool: codegen_attach_detach() emits attach helper for
  uncreated struct_ops
--

commit 5cc89494fb6061133b6673a4a512cf419242013b
Author: Alexei Starovoitov <ast@kernel.org>

libbpf, bpftool: Keep places of programs and maps in light skeletons

This commit indexes programs and maps in light skeletons by their
positions in the BPF object rather than load order, so non-autoloaded
programs and non-autocreated maps keep their slots with fd 0. It also
updates bpftool skeleton attach generation to skip non-autoloaded
programs and non-autocreated struct_ops maps.

> diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
> index da5f7c9d99abe..97b2a06f6ca0c 100644
> --- a/tools/bpf/bpftool/gen.c
> +++ b/tools/bpf/bpftool/gen.c

[ ... ]

> @@ -656,7 +659,7 @@ static void codegen_attach_detach(struct bpf_object *obj, const char *obj_name)
>  			continue;
>  		if (bpf_map__type(map) != BPF_MAP_TYPE_STRUCT_OPS)
>  			continue;
> -		if (!(bpf_map__map_flags(map) & BPF_F_LINK))
> +		if (!(bpf_map__map_flags(map) & BPF_F_LINK) || !bpf_map__autocreate(map))
>  			continue;
>  
>  		codegen("\

[Severity: Low]
Should the earlier per-map helper loop in codegen_attach_detach() also
check !bpf_map__autocreate(map)?

The aggregate <obj>__attach() loop skips non-autocreated struct_ops maps,
but the earlier bpf_object__for_each_map() loop still emits
<obj>__<map>__attach() calling skel_link_create() unconditionally with
map_fd equal to 0.

Calling that per-map helper directly issues BPF_LINK_CREATE on fd 0,
failing with -EINVAL or -EBADF (or silently attaching an unrelated
struct_ops map if fd 0 was closed and reused).  Skipping the helper or
emitting a no-op returning 0 when !bpf_map__autocreate(map) avoids this.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205010519.2565529-1-alexei.starovoitov@gmail.com?part=1

  reply	other threads:[~2026-12-05  1:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  1:05 [PATCH bpf-next 0/4] libbpf: Fixes for light skeletons Alexei Starovoitov
2026-12-05  1:05 ` [PATCH bpf-next 1/4] libbpf, bpftool: Keep places of programs and maps in " Alexei Starovoitov
2026-12-05  1:25   ` sashiko-bot [this message]
2026-12-05  1:05 ` [PATCH bpf-next 2/4] libbpf: Do not map an arena in gen_loader Alexei Starovoitov
2026-12-05  1:05 ` [PATCH bpf-next 3/4] libbpf: Clear the stack of a loader without a helper Alexei Starovoitov
2026-12-05  1:05 ` [PATCH bpf-next 4/4] selftests/bpf: Test places of programs and maps in a light skeleton Alexei Starovoitov
2026-12-05  2:40 ` [PATCH bpf-next 0/4] libbpf: Fixes for light skeletons patchwork-bot+netdevbpf

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=sashiko-outbox-250893@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.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 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.