Skip to content

Commit e8c8361

Browse files
author
Alexei Starovoitov
committed
selftests/bpf: Fix progs/test_deny_namespace.c issues.
The following build error can be seen: progs/test_deny_namespace.c:22:19: error: call to undeclared function 'BIT_LL'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] __u64 cap_mask = BIT_LL(CAP_SYS_ADMIN); The struct kernel_cap_struct no longer exists in the kernel as well. Adjust bpf prog to fix both issues. Fixes: f122a08 ("capability: just use a 'u64' instead of a 'u32[2]' array") Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 32513d4 commit e8c8361

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

tools/testing/selftests/bpf/progs/test_deny_namespace.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,19 @@
55
#include <errno.h>
66
#include <linux/capability.h>
77

8-
struct kernel_cap_struct {
9-
__u64 val;
10-
} __attribute__((preserve_access_index));
8+
typedef struct { unsigned long long val; } kernel_cap_t;
119

1210
struct cred {
13-
struct kernel_cap_struct cap_effective;
11+
kernel_cap_t cap_effective;
1412
} __attribute__((preserve_access_index));
1513

1614
char _license[] SEC("license") = "GPL";
1715

1816
SEC("lsm.s/userns_create")
1917
int BPF_PROG(test_userns_create, const struct cred *cred, int ret)
2018
{
21-
struct kernel_cap_struct caps = cred->cap_effective;
22-
__u64 cap_mask = BIT_LL(CAP_SYS_ADMIN);
19+
kernel_cap_t caps = cred->cap_effective;
20+
__u64 cap_mask = 1ULL << CAP_SYS_ADMIN;
2321

2422
if (ret)
2523
return 0;

0 commit comments

Comments
 (0)