core: add options to delegate BPFFS token creation

Add four new options BPFDelegate{Commands,Maps,Programs,Attachments}=
in order to delegate to a BPFFS instance the permission to create tokens.

The value is a list of options taken from:
https://github.com/torvalds/linux/blob/v6.14/include/uapi/linux/bpf.h#L922-L1121
The special value "any" means to allow every possible values.

More informations about BPF tokens here:
https://lwn.net/Articles/947173/
This commit is contained in:
Matteo Croce
2025-07-08 22:35:29 +02:00
parent 3a47437fc9
commit ea9826eb94
21 changed files with 677 additions and 8 deletions
+13
View File
@@ -1156,6 +1156,19 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) {
prefix, proc_subset_to_string(c->proc_subset),
prefix, private_bpf_to_string(c->private_bpf));
if (c->private_bpf == PRIVATE_BPF_YES) {
_cleanup_free_ char
*commands = bpf_delegate_commands_to_string(c->bpf_delegate_commands),
*maps = bpf_delegate_maps_to_string(c->bpf_delegate_maps),
*programs = bpf_delegate_programs_to_string(c->bpf_delegate_programs),
*attachments = bpf_delegate_attachments_to_string(c->bpf_delegate_attachments);
fprintf(f, "%sBPFDelegateCommands: %s\n", prefix, strna(commands));
fprintf(f, "%sBPFDelegateMaps: %s\n", prefix, strna(maps));
fprintf(f, "%sBPFDelegatePrograms: %s\n", prefix, strna(programs));
fprintf(f, "%sBPFDelegateAttachments: %s\n", prefix, strna(attachments));
}
if (c->set_login_environment >= 0)
fprintf(f, "%sSetLoginEnvironment: %s\n", prefix, yes_no(c->set_login_environment > 0));