bpf: Add BPF token support to BPF_PROG_LOAD command
authorAndrii Nakryiko <andrii@kernel.org>
Wed, 24 Jan 2024 02:21:03 +0000 (18:21 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 25 Jan 2024 00:21:01 +0000 (16:21 -0800)
commitcaf8f28e036c4ba1e823355da6c0c01c39e70ab9
treebc60a1165bbbf9e13a1fa840f27298af3cbee67d
parent9ea7c4bf17e39d463eb4782f948f401d9764b1b3
bpf: Add BPF token support to BPF_PROG_LOAD command

Add basic support of BPF token to BPF_PROG_LOAD. BPF_F_TOKEN_FD flag
should be set in prog_flags field when providing prog_token_fd.

Wire through a set of allowed BPF program types and attach types,
derived from BPF FS at BPF token creation time. Then make sure we
perform bpf_token_capable() checks everywhere where it's relevant.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20240124022127.2379740-7-andrii@kernel.org
include/linux/bpf.h
include/uapi/linux/bpf.h
kernel/bpf/core.c
kernel/bpf/inode.c
kernel/bpf/syscall.c
kernel/bpf/token.c
tools/include/uapi/linux/bpf.h
tools/testing/selftests/bpf/prog_tests/libbpf_probes.c
tools/testing/selftests/bpf/prog_tests/libbpf_str.c