lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210605111034.1810858-20-jolsa@kernel.org>
Date:   Sat,  5 Jun 2021 13:10:34 +0200
From:   Jiri Olsa <jolsa@...nel.org>
To:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andriin@...com>,
        "Steven Rostedt (VMware)" <rostedt@...dmis.org>
Cc:     netdev@...r.kernel.org, bpf@...r.kernel.org,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...omium.org>, Daniel Xu <dxu@...uu.xyz>,
        Viktor Malik <vmalik@...hat.com>
Subject: [PATCH 19/19] selftests/bpf: Temporary fix for fentry_fexit_multi_test

When multi_arg_check is used from 2 different places I'm getting
compilation fail, which I did not deciphered yet:

  $ CLANG=/opt/clang/bin/clang LLC=/opt/clang/bin/llc make
    CLNG-BPF [test_maps] fentry_fexit_multi_test.o
  progs/fentry_fexit_multi_test.c:18:2: error: too many args to t24: i64 = \
  GlobalAddress<void (i64, i64, i64, i64, i64, i64, i64, i64*)* @multi_arg_check> 0, \
  progs/fentry_fexit_multi_test.c:18:2 @[ progs/fentry_fexit_multi_test.c:16:5 ]
          multi_arg_check(ip, a, b, c, d, e, f, &test1_arg_result);
          ^
  progs/fentry_fexit_multi_test.c:25:2: error: too many args to t32: i64 = \
  GlobalAddress<void (i64, i64, i64, i64, i64, i64, i64, i64*)* @multi_arg_check> 0, \
  progs/fentry_fexit_multi_test.c:25:2 @[ progs/fentry_fexit_multi_test.c:23:5 ]
          multi_arg_check(ip, a, b, c, d, e, f, &test2_arg_result);
          ^
  In file included from progs/fentry_fexit_multi_test.c:5:
  /home/jolsa/linux-qemu/tools/testing/selftests/bpf/multi_check.h:9:6: error: defined with too many args
  void multi_arg_check(unsigned long ip, __u64 a, __u64 b, __u64 c, __u64 d, __u64 e, __u64 f, __u64 *test_result)
       ^
  /home/jolsa/linux-qemu/tools/testing/selftests/bpf/multi_check.h:9:6: error: defined with too many args
  /home/jolsa/linux-qemu/tools/testing/selftests/bpf/multi_check.h:9:6: error: defined with too many args
  5 errors generated.
  make: *** [Makefile:470: /home/jolsa/linux-qemu/tools/testing/selftests/bpf/fentry_fexit_multi_test.o] Error 1

As a temporary fix adding 2 instaces of multi_arg_check
function, one for each caller.

Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
 tools/testing/selftests/bpf/multi_check.h     | 41 ++++++++++---------
 .../bpf/progs/fentry_fexit_multi_test.c       |  7 +++-
 .../selftests/bpf/progs/fentry_multi_test.c   |  4 +-
 .../selftests/bpf/progs/fexit_multi_test.c    |  4 +-
 4 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/tools/testing/selftests/bpf/multi_check.h b/tools/testing/selftests/bpf/multi_check.h
index 36c2a93f9be3..f720a6f9c6e4 100644
--- a/tools/testing/selftests/bpf/multi_check.h
+++ b/tools/testing/selftests/bpf/multi_check.h
@@ -5,26 +5,27 @@
 
 extern unsigned long long bpf_fentry_test[8];
 
-static __attribute__((unused)) inline
-void multi_arg_check(unsigned long ip, __u64 a, __u64 b, __u64 c, __u64 d, __u64 e, __u64 f, __u64 *test_result)
-{
-	if (ip == bpf_fentry_test[0]) {
-		*test_result += (int) a == 1;
-	} else if (ip == bpf_fentry_test[1]) {
-		*test_result += (int) a == 2 && (__u64) b == 3;
-	} else if (ip == bpf_fentry_test[2]) {
-		*test_result += (char) a == 4 && (int) b == 5 && (__u64) c == 6;
-	} else if (ip == bpf_fentry_test[3]) {
-		*test_result += (void *) a == (void *) 7 && (char) b == 8 && (int) c == 9 && (__u64) d == 10;
-	} else if (ip == bpf_fentry_test[4]) {
-		*test_result += (__u64) a == 11 && (void *) b == (void *) 12 && (short) c == 13 && (int) d == 14 && (__u64) e == 15;
-	} else if (ip == bpf_fentry_test[5]) {
-		*test_result += (__u64) a == 16 && (void *) b == (void *) 17 && (short) c == 18 && (int) d == 19 && (void *) e == (void *) 20 && (__u64) f == 21;
-	} else if (ip == bpf_fentry_test[6]) {
-		*test_result += 1;
-	} else if (ip == bpf_fentry_test[7]) {
-		*test_result += 1;
-	}
+#define MULTI_ARG_CHECK(_name) \
+static __attribute__((unused)) inline \
+void _name ## _multi_arg_check(unsigned long ip, __u64 a, __u64 b, __u64 c, __u64 d, __u64 e, __u64 f, __u64 *test_result)						\
+{																					\
+	if (ip == bpf_fentry_test[0]) {																	\
+		*test_result +=	(int) a == 1;																\
+	} else if (ip == bpf_fentry_test[1]) {																\
+		*test_result +=	(int) a == 2 && (__u64) b == 3;														\
+	} else if (ip == bpf_fentry_test[2]) {																\
+		*test_result +=	(char) a == 4 && (int) b == 5 && (__u64) c == 6;											\
+	} else if (ip == bpf_fentry_test[3]) {																\
+		*test_result +=	(void *) a == (void *) 7 && (char) b == 8 && (int) c == 9 && (__u64) d == 10;								\
+	} else if (ip == bpf_fentry_test[4]) {																\
+		*test_result +=	(__u64) a == 11 && (void *) b == (void *) 12 && (short) c == 13 && (int) d == 14 && (__u64) e == 15;					\
+	} else if (ip == bpf_fentry_test[5]) {																\
+		*test_result +=	(__u64) a == 16 && (void *) b == (void *) 17 && (short) c == 18 && (int) d == 19 && (void *) e == (void *) 20 && (__u64) f == 21;	\
+	} else if (ip == bpf_fentry_test[6]) {																\
+		*test_result += 1;																	\
+	} else if (ip == bpf_fentry_test[7]) {																\
+		*test_result += 1;																	\
+	}																				\
 }
 
 static __attribute__((unused)) inline
diff --git a/tools/testing/selftests/bpf/progs/fentry_fexit_multi_test.c b/tools/testing/selftests/bpf/progs/fentry_fexit_multi_test.c
index e25ab0085399..dc5b51f20b84 100644
--- a/tools/testing/selftests/bpf/progs/fentry_fexit_multi_test.c
+++ b/tools/testing/selftests/bpf/progs/fentry_fexit_multi_test.c
@@ -6,6 +6,9 @@
 
 char _license[] SEC("license") = "GPL";
 
+MULTI_ARG_CHECK(fentry)
+MULTI_ARG_CHECK(fexit)
+
 unsigned long long bpf_fentry_test[8];
 
 __u64 test1_arg_result = 0;
@@ -15,14 +18,14 @@ __u64 test2_ret_result = 0;
 SEC("fentry.multi/bpf_fentry_test*")
 int BPF_PROG(test1, unsigned long ip, __u64 a, __u64 b, __u64 c, __u64 d, __u64 e, __u64 f)
 {
-	multi_arg_check(ip, a, b, c, d, e, f, &test1_arg_result);
+	fentry_multi_arg_check(ip, a, b, c, d, e, f, &test1_arg_result);
 	return 0;
 }
 
 SEC("fexit.multi/")
 int BPF_PROG(test2, unsigned long ip, __u64 a, __u64 b, __u64 c, __u64 d, __u64 e, __u64 f, int ret)
 {
-	multi_arg_check(ip, a, b, c, d, e, f, &test2_arg_result);
+	fexit_multi_arg_check(ip, a, b, c, d, e, f, &test2_arg_result);
 	multi_ret_check(ip, ret, &test2_ret_result);
 	return 0;
 }
diff --git a/tools/testing/selftests/bpf/progs/fentry_multi_test.c b/tools/testing/selftests/bpf/progs/fentry_multi_test.c
index a443fc958e5a..b3a025632e77 100644
--- a/tools/testing/selftests/bpf/progs/fentry_multi_test.c
+++ b/tools/testing/selftests/bpf/progs/fentry_multi_test.c
@@ -6,6 +6,8 @@
 
 char _license[] SEC("license") = "GPL";
 
+MULTI_ARG_CHECK(fentry)
+
 unsigned long long bpf_fentry_test[8];
 
 __u64 test_result = 0;
@@ -13,6 +15,6 @@ __u64 test_result = 0;
 SEC("fentry.multi/bpf_fentry_test*")
 int BPF_PROG(test, unsigned long ip, __u64 a, __u64 b, __u64 c, __u64 d, __u64 e, __u64 f)
 {
-	multi_arg_check(ip, a, b, c, d, e, f, &test_result);
+	fentry_multi_arg_check(ip, a, b, c, d, e, f, &test_result);
 	return 0;
 }
diff --git a/tools/testing/selftests/bpf/progs/fexit_multi_test.c b/tools/testing/selftests/bpf/progs/fexit_multi_test.c
index 365575cf05a0..8af0d65128d6 100644
--- a/tools/testing/selftests/bpf/progs/fexit_multi_test.c
+++ b/tools/testing/selftests/bpf/progs/fexit_multi_test.c
@@ -6,6 +6,8 @@
 
 char _license[] SEC("license") = "GPL";
 
+MULTI_ARG_CHECK(fexit)
+
 unsigned long long bpf_fentry_test[8];
 
 __u64 test_arg_result = 0;
@@ -14,7 +16,7 @@ __u64 test_ret_result = 0;
 SEC("fexit.multi/bpf_fentry_test*")
 int BPF_PROG(test, unsigned long ip, __u64 a, __u64 b, __u64 c, __u64 d, __u64 e, __u64 f, int ret)
 {
-	multi_arg_check(ip, a, b, c, d, e, f, &test_arg_result);
+	fexit_multi_arg_check(ip, a, b, c, d, e, f, &test_arg_result);
 	multi_ret_check(ip, ret, &test_ret_result);
 	return 0;
 }
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ