libbpf: Support gen loader attach
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest5 patches 1 replyIn review
- v25 patches 0 repliesSuperseded
- v15 patches 0 repliesSuperseded
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | libbpf: Count entry programs for bpf_gen__init()tools/ | +7 | 0 replies | |
| 2/5 | libbpf: Track generated loader link FDstools/ tools/ tools/ +1 more | +24 | 0 replies | |
| 3/5 | libbpf: Emit BPF_LINK_CREATE calls in generated loaderstools/ tools/ tools/ | +71 | 1 reply | |
| 4/5 | bpftool: Add attach option for light skeleton generationtools/ tools/ tools/ | +56 | 0 replies | |
| 5/5 | selftests/bpf: Test gen loader attachtools/ tools/ | +277 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.
Cover letter [PATCH bpf-next v3 0/5] libbpf: Support gen loader attach
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.
v3 updates:
- rebased again because I had a debug commit in between master and my patches that somehow surprisingly conflicted... sorry for the spam!
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/[email protected]/
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