summaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorAndrii Nakryiko <andrii@kernel.org>2024-01-23 18:21:13 -0800
committerAlexei Starovoitov <ast@kernel.org>2024-01-24 16:21:02 -0800
commitfcb9597ff7d1f7c772c1237dd2d04dd44e622501 (patch)
treedc73432da5e07a162b44ab6c0636b10ea2e2aa9e /security
parent404cbc149c3866e6ec2bfe1bce52c8864e1f81fc (diff)
downloadlinux-fcb9597ff7d1f7c772c1237dd2d04dd44e622501.tar.gz
linux-fcb9597ff7d1f7c772c1237dd2d04dd44e622501.tar.bz2
linux-fcb9597ff7d1f7c772c1237dd2d04dd44e622501.zip
selftests/bpf: Add BPF token-enabled tests
Add a selftest that attempts to conceptually replicate intended BPF token use cases inside user namespaced container. Child process is forked. It is then put into its own userns and mountns. Child creates BPF FS context object. This ensures child userns is captured as the owning userns for this instance of BPF FS. Given setting delegation mount options is privileged operation, we ensure that child cannot set them. This context is passed back to privileged parent process through Unix socket, where parent sets up delegation options, creates, and mounts it as a detached mount. This mount FD is passed back to the child to be used for BPF token creation, which allows otherwise privileged BPF operations to succeed inside userns. We validate that all of token-enabled privileged commands (BPF_BTF_LOAD, BPF_MAP_CREATE, and BPF_PROG_LOAD) work as intended. They should only succeed inside the userns if a) BPF token is provided with proper allowed sets of commands and types; and b) namespaces CAP_BPF and other privileges are set. Lacking a) or b) should lead to -EPERM failures. Based on suggested workflow by Christian Brauner ([0]). [0] https://lore.kernel.org/bpf/20230704-hochverdient-lehne-eeb9eeef785e@brauner/ Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20240124022127.2379740-17-andrii@kernel.org
Diffstat (limited to 'security')
0 files changed, 0 insertions, 0 deletions