]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpftool: Add support for signing BPF programs
authorKP Singh <kpsingh@kernel.org>
Sun, 21 Sep 2025 16:01:19 +0000 (18:01 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 23 Sep 2025 02:17:55 +0000 (19:17 -0700)
commit40863f4d6ef2c34bb00dd1070dfaf9d5f27a497e
treefb250b7fb5bee5fc80c1e42bad41552fcd22804e
parentea923080c14578504c2e142760d9de547e38e87c
bpftool: Add support for signing BPF programs

Two modes of operation being added:

Add two modes of operation:

* For prog load, allow signing a program immediately before loading. This
  is essential for command-line testing and administration.

      bpftool prog load -S -k <private_key> -i <identity_cert> fentry_test.bpf.o

* For gen skeleton, embed a pre-generated signature into the C skeleton
  file. This supports the use of signed programs in compiled applications.

      bpftool gen skeleton -S -k <private_key> -i <identity_cert> fentry_test.bpf.o

Generation of the loader program and its metadata map is implemented in
libbpf (bpf_obj__gen_loader). bpftool generates a skeleton that loads
the program and automates the required steps: freezing the map, creating
an exclusive map, loading, and running. Users can use standard libbpf
APIs directly or integrate loader program generation into their own
toolchains.

Signed-off-by: KP Singh <kpsingh@kernel.org>
Acked-by: Quentin Monnet <qmo@kernel.org>
Link: https://lore.kernel.org/r/20250921160120.9711-5-kpsingh@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/bpf/bpftool/Documentation/bpftool-gen.rst
tools/bpf/bpftool/Documentation/bpftool-prog.rst
tools/bpf/bpftool/Makefile
tools/bpf/bpftool/cgroup.c
tools/bpf/bpftool/gen.c
tools/bpf/bpftool/main.c
tools/bpf/bpftool/main.h
tools/bpf/bpftool/prog.c
tools/bpf/bpftool/sign.c [new file with mode: 0644]