From: Mahe Tardy <mahe.tardy@gmail.com>
To: bpf@vger.kernel.org
Cc: 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>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Emil Tsalapatis <emil@etsalapatis.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
Shuah Khan <shuah@kernel.org>, Mahe Tardy <mahe.tardy@gmail.com>,
Tianyi Chen <hi@tychen.cc>, Gyutae Bae <gyutae.bae@navercorp.com>,
Hui Su <sh_def@163.com>, Josef Bacik <josef@toxicpanda.com>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: [PATCH bpf-next v2 0/5] libbpf: Support gen loader attach
Date: Mon, 2 Nov 2026 19:41:39 +0000 [thread overview]
Message-ID: <20261102194145.620210-1-mahe.tardy@gmail.com> (raw)
Hey,
I've been working on this in the context of Shirudo[^1]. The current
limitations we face is that gen_loader cannot attach the program it
loads so we still need a userspace component to be allowed to
BPF_LINK_CREATE and we'd like to gradually remove the allowed operations
done in userspace to solely rely on the signed program.
Note that there's no kernel modification in this series, it adds the
gen_attach options and code generation to libbpf and do the wiring from
bpftool. The kernel side was already allowed thanks to 'b1d18a7574d0
("bpf: Extend sys_bpf commands for bpf_syscall programs.")'.
Also note that I did some analyzis with Sashiko and it's been
complaining because I've followed the approach with the prog fds being
initialized to 0 (and not fixing the two fds to init to -1 sentinel
value), so maybe we should pre-patch this.
Lastly, I don't know much about bpftool so unsure if the way I've added
it is the most appropriate way for the lskel attach option.
v2 updates:
- rebased to includes changes from the 'libbpf: BPF program manual
loading'[^2] patch series that conflicts with that series.
[^1]: https://lpc.events/event/20/contributions/2437/
[^2]: https://lore.kernel.org/bpf/20261029223348.3730738-1-andrey.grodzovsky@crowdstrike.com/
Mahe Tardy (5):
libbpf: Count entry programs for bpf_gen__init()
libbpf: Track generated loader link FDs
libbpf: Emit BPF_LINK_CREATE calls in generated loaders
bpftool: Add attach option for light skeleton generation
selftests/bpf: Test gen loader attach
.../bpf/bpftool/Documentation/bpftool-gen.rst | 11 +-
tools/bpf/bpftool/bash-completion/bpftool | 2 +-
tools/bpf/bpftool/gen.c | 67 +++--
tools/lib/bpf/bpf_gen_internal.h | 7 +
tools/lib/bpf/gen_loader.c | 41 +++-
tools/lib/bpf/libbpf.c | 55 ++++-
tools/lib/bpf/libbpf.h | 3 +-
tools/lib/bpf/skel_internal.h | 4 +
.../bpf/prog_tests/gen_loader_attach.c | 229 ++++++++++++++++++
.../selftests/bpf/progs/gen_loader_attach.c | 48 ++++
10 files changed, 435 insertions(+), 32 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/gen_loader_attach.c
create mode 100644 tools/testing/selftests/bpf/progs/gen_loader_attach.c
--
2.43.0
next reply other threads:[~2026-11-02 19:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 19:41 Mahe Tardy [this message]
2026-11-02 19:41 ` [PATCH bpf-next v2 1/5] libbpf: Count entry programs for bpf_gen__init() Mahe Tardy
2026-11-02 19:41 ` [PATCH bpf-next v2 2/5] libbpf: Track generated loader link FDs Mahe Tardy
2026-11-02 19:41 ` [PATCH bpf-next v2 3/5] libbpf: Emit BPF_LINK_CREATE calls in generated loaders Mahe Tardy
2026-11-02 19:41 ` [PATCH bpf-next v2 4/5] bpftool: Add attach option for light skeleton generation Mahe Tardy
2026-11-02 19:41 ` [PATCH bpf-next v2 5/5] selftests/bpf: Test gen loader attach Mahe Tardy
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=20261102194145.620210-1-mahe.tardy@gmail.com \
--to=mahe.tardy@gmail.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=gyutae.bae@navercorp.com \
--cc=hi@tychen.cc \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=josef@toxicpanda.com \
--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=sh_def@163.com \
--cc=shuah@kernel.org \
--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®