capability: test_deny_namespace breakage due to capability conversion to u64
Subsystems (3)
PATCH 1/1 capability: test_deny_namespace breakage due to capability conversion to u64
Commit f122a08b197d ("capability: just use a 'u64' instead of a 'u32[2]' array") attempts to use BIT_LL() but actually wanted to use BIT_ULL(), fix it up to make the test compile and run again.
--- tools/testing/selftests/bpf/Makefile | 2 +- tools/testing/selftests/bpf/progs/test_deny_namespace.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/Makefile +1 -1
@@ -353,7 +353,7 @@ endif CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) BPF_CFLAGS = -g -Werror -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN) \ -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR) \ - -I$(abspath $(OUTPUT)/../usr/include) + -I$(abspath $(OUTPUT)/../usr/include) -I$(TOOLSINCDIR) CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \ -Wno-compare-distinct-pointer-types
tools/testing/selftests/bpf/progs/test_deny_namespace.c +2 -1
@@ -4,6 +4,7 @@#include <bpf/bpf_tracing.h> #include <errno.h> #include <linux/capability.h> +#include <vdso/bits.h> struct kernel_cap_struct {__u64 val;
@@ -19,7 +20,7 @@ SEC("lsm.s/userns_create")int BPF_PROG (test_userns_create ,const struct cred *cred,int ret) {struct kernel_cap_struct caps = cred->cap_effective; -__u64 cap_mask =BIT_LL (CAP_SYS_ADMIN ); +__u64 cap_mask =BIT_ULL (CAP_SYS_ADMIN );if (ret)return 0 ;
Signature · 1 line
2.39.2
Quoted 4 lines · Sasha Levin
Commit
f122a08b197d("capability: just use a 'u64' instead of a 'u32[2]' array") attempts to useBIT_LL()but actually wanted to useBIT_ULL(), fix it up to make the test compile and run again.
This got fixed differently by e8c8361cfdbf ("selftests/bpf: Fix progs/test_deny_namespace.c issues").
I wonder what drugs made me think BIT_LL() was ok. Maybe my wife puts something in the coffee?
Linus
Quoted 6 lines · Linus Torvalds
Quoted 4 lines · Sasha Levin
Commit
f122a08b197d("capability: just use a 'u64' instead of a 'u32[2]' array") attempts to useBIT_LL()but actually wanted to useBIT_ULL(), fix it up to make the test compile and run again.
It would only fix the compilation error, but the test would still fail.
Quoted 2 lines
This got fixed differently by
e8c8361cfdbf("selftests/bpf: Fixprogs/test_deny_namespace.cissues").
exactly. It's not just the macro that had to be adjusted.
Quoted 2 lines
I wonder what drugs made me think
BIT_LL()was ok. Maybe my wife puts something in the coffee?
$ make C=2 kernel/bpf/core.o kernel/bpf/core.c:1822:43: error: arithmetics on pointers to functions kernel/bpf/core.c:1827:48: error: arithmetics on pointers to functions kernel/bpf/core.c:2073:77: error: subtraction of functions? Share your drugs
:)