1 // SPDX-License-Identifier: GPL-2.0
3 #include <bpf/bpf_helpers.h>
4 #include <bpf/bpf_tracing.h>
6 #include <linux/capability.h>
8 typedef struct { unsigned long long val; } kernel_cap_t;
11 kernel_cap_t cap_effective;
12 } __attribute__((preserve_access_index));
14 char _license[] SEC("license") = "GPL";
16 SEC("lsm.s/userns_create")
17 int BPF_PROG(test_userns_create, const struct cred *cred, int ret)
19 kernel_cap_t caps = cred->cap_effective;
20 __u64 cap_mask = 1ULL << CAP_SYS_ADMIN;
26 if (caps.val & cap_mask)