Skip to content

Libbpf userspace function bpf_object__gen_loader

0.5.0

Instruct the BPF object to generate a loader program instead of actually loading the object.

Definition

int bpf_object__gen_loader(struct bpf_object *obj, struct gen_loader_opts *opts);

Usage

This method instructs the BPF object to generate a loader program instead of actually loading the object. It records all steps it would take from userspace and translates them into a program of type BPF_PROG_TYPE_SYSCALL.

This is part of an attempt to create cryptographically signed BPF programs. BPF programs are commonly modified by the loader before being loaded into the kernel which makes it impossible to sign the ELF, since the actual bytecode to be loaded will be different. So the idea was to generate a loader program at compile time, it could be signed.

Example

Docs could be improved

This part of the docs is incomplete, contributions are very welcome