From: sashiko-bot@kernel.org
To: "Siddharth Nayyar" <sidnayyar@google.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v4 1/3] libbpf: load vmlinux BTF in gen_loader mode for struct_ops
Date: Wed, 27 May 2026 13:25:26 +0000 [thread overview]
Message-ID: <20260527132526.EDBDF1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260527-libbpf-load-vmlinux-btf-in-gen_loader-mode-v4-1-27daa15487a9@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Enabling light skeleton generation for `struct_ops` maps exposes incomplete and fundamentally broken loader logic, which will always fail on the target system.
--
commit 241c33de1404c9ec6cd0b388a0a3bc61171e6646
Author: Siddharth Nayyar <sidnayyar@google.com>
libbpf: load vmlinux BTF in gen_loader mode for struct_ops
This patch modifies the BTF loading logic in libbpf to ensure vmlinux BTF
is loaded even in gen_loader mode if the BPF object contains struct_ops maps.
This provides the necessary type information for generating light skeletons.
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 3a80a018fc7d5..b159faae7f9c6 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
[ ... ]
> @@ -3590,7 +3590,11 @@ static int bpf_object__load_vmlinux_btf(struct bpf_object *obj, bool force)
> int err;
>
> /* btf_vmlinux could be loaded earlier */
> - if (obj->btf_vmlinux || obj->gen_loader)
> + if (obj->btf_vmlinux)
> + return 0;
> +
> + /* only struct_ops maps need btf_vmlinux in gen_loader */
> + if (obj->gen_loader && !obj_maps_need_vmlinux_btf(obj))
> return 0;
[Severity: High]
Does enabling struct_ops for light skeletons result in a generated loader
that works correctly on the target system?
It appears the gen_loader logic statically embeds the build host's
btf_vmlinux_value_type_id into the BPF_MAP_CREATE attributes buffer. Since
BTF IDs vary across kernel versions and configurations, won't passing the
build host's BTF ID to a different target kernel cause the syscall to fail
with -EINVAL or incorrectly associate the map with the wrong kernel structure?
Shouldn't the loader dynamically resolve this ID using bpf_btf_find_by_name_kind
on the target kernel instead?
Additionally, struct_ops maps require their map values to be populated with
the runtime FDs of the loaded BPF programs. Does gen_loader currently have
the necessary logic to emit BPF instructions that read dynamically generated
prog_fds from the loader's stack, patch them into the map value buffer, and
update the map?
Furthermore, does the skel__attach() function generated by
bpftool gen skeleton -L handle struct_ops map attachment? It seems to only
iterate over programs, entirely omitting the struct_ops map attachment that
is normally handled by bpf_map__attach_struct_ops().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260527-libbpf-load-vmlinux-btf-in-gen_loader-mode-v4-0-27daa15487a9@google.com?part=1
next prev parent reply other threads:[~2026-05-27 13:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-27 12:52 [PATCH v4 0/3] libbpf: support STRUCT_OPS in light skeletons Siddharth Nayyar
2026-05-27 12:52 ` [PATCH v4 1/3] libbpf: load vmlinux BTF in gen_loader mode for struct_ops Siddharth Nayyar
2026-05-27 13:25 ` sashiko-bot [this message]
2026-05-27 13:39 ` bot+bpf-ci
2026-05-27 14:17 ` Alexei Starovoitov
2026-05-27 12:52 ` [PATCH v4 2/3] libbpf: zero out btf_key_type_id for STRUCT_OPS maps Siddharth Nayyar
2026-05-27 13:39 ` bot+bpf-ci
2026-05-27 12:52 ` [PATCH v4 3/3] libbpf: plumb btf_vmlinux_value_type_id and btf_fd in gen_loader Siddharth Nayyar
2026-05-27 13:39 ` bot+bpf-ci
2026-05-27 14:10 ` sashiko-bot
2026-05-27 14:27 ` Sid Nayyar
2026-05-28 21:35 ` [PATCH v4 0/3] libbpf: support STRUCT_OPS in light skeletons Andrii Nakryiko
2026-05-29 10:31 ` Sid Nayyar
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=20260527132526.EDBDF1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sidnayyar@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