All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] capability: test_deny_namespace breakage due to capability conversion to u64
@ 2023-03-24 12:36 Sasha Levin
  2023-03-24 16:39 ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: Sasha Levin @ 2023-03-24 12:36 UTC (permalink / raw)
  To: torvalds; +Cc: andrii, mykolal, bpf, linux-kselftest, linux-kernel, Sasha Levin

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.

Fixes: f122a08b197d ("capability: just use a 'u64' instead of a 'u32[2]' array")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/testing/selftests/bpf/Makefile                    | 2 +-
 tools/testing/selftests/bpf/progs/test_deny_namespace.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index b677dcd0b77af..91a4e61b61f6d 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -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
diff --git a/tools/testing/selftests/bpf/progs/test_deny_namespace.c b/tools/testing/selftests/bpf/progs/test_deny_namespace.c
index 591104e79812e..0a619c34d692d 100644
--- a/tools/testing/selftests/bpf/progs/test_deny_namespace.c
+++ b/tools/testing/selftests/bpf/progs/test_deny_namespace.c
@@ -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;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] capability: test_deny_namespace breakage due to capability conversion to u64
  2023-03-24 12:36 [PATCH] capability: test_deny_namespace breakage due to capability conversion to u64 Sasha Levin
@ 2023-03-24 16:39 ` Linus Torvalds
  2023-03-24 19:48   ` Alexei Starovoitov
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2023-03-24 16:39 UTC (permalink / raw)
  To: Sasha Levin; +Cc: andrii, mykolal, bpf, linux-kselftest, linux-kernel

On Fri, Mar 24, 2023 at 5:36 AM Sasha Levin <sashal@kernel.org> wrote:
>
> 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.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] capability: test_deny_namespace breakage due to capability conversion to u64
  2023-03-24 16:39 ` Linus Torvalds
@ 2023-03-24 19:48   ` Alexei Starovoitov
  0 siblings, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2023-03-24 19:48 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Sasha Levin, Andrii Nakryiko, Mykola Lysenko, bpf,
	open list:KERNEL SELFTEST FRAMEWORK, LKML

On Fri, Mar 24, 2023 at 9:49 AM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> On Fri, Mar 24, 2023 at 5:36 AM Sasha Levin <sashal@kernel.org> wrote:
> >
> > 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.

It would only fix the compilation error, but the test would still fail.

> This got fixed differently by e8c8361cfdbf ("selftests/bpf: Fix
> progs/test_deny_namespace.c issues").

exactly. It's not just the macro that had to be adjusted.

> 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

:)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-24 19:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24 12:36 [PATCH] capability: test_deny_namespace breakage due to capability conversion to u64 Sasha Levin
2023-03-24 16:39 ` Linus Torvalds
2023-03-24 19:48   ` Alexei Starovoitov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.