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: <1b37795dcca093e8d5a698b68f82dd544118e6f6.1544474487.git.sdf@google.com>
Date:   Mon, 10 Dec 2018 12:43:10 -0800
From:   Stanislav Fomichev <sdf@...gle.com>
To:     netdev@...r.kernel.org
Cc:     davem@...emloft.net, ast@...nel.org, daniel@...earbox.net,
        jakub.kicinski@...ronome.com, Stanislav Fomichev <sdf@...gle.com>
Subject: [PATCH bpf-next v2 2/2] selftests/bpf: skip verifier sockmap tests on
 kernels without support

Same idea as in the previous commit (for maps), but for verifier.

Selectively disable sockmap and xskmap tests if appropriate option
is not specified in the kernel config.
When building out of tree/without autoconf.h, fall back to 'enabled'.

Signed-off-by: Stanislav Fomichev <sdf@...gle.com>
---
 tools/testing/selftests/bpf/test_verifier.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 957e4711c46c..e0a8bfba2104 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -25,6 +25,7 @@
 #include <limits.h>
 
 #include <sys/capability.h>
+#include <tools/config.h>
 
 #include <linux/unistd.h>
 #include <linux/filter.h>
@@ -40,6 +41,9 @@
 # if defined(__i386) || defined(__x86_64) || defined(__s390x__) || defined(__aarch64__)
 #  define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 1
 # endif
+/* fallback to all features enabled */
+# define CONFIG_BPF_STREAM_PARSER 1
+# define CONFIG_XDP_SOCKETS 1
 #endif
 #include "bpf_rlimit.h"
 #include "bpf_rand.h"
@@ -86,6 +90,7 @@ struct bpf_test {
 	uint8_t flags;
 	__u8 data[TEST_DATA_LEN];
 	void (*fill_helper)(struct bpf_test *self);
+	bool config_disabled;
 };
 
 /* Note we want this to be 64 bit aligned so that the end of our array is
@@ -4639,6 +4644,7 @@ static struct bpf_test tests[] = {
 		.result = REJECT,
 		.errstr = "cannot pass map_type 15 into func bpf_map_lookup_elem",
 		.prog_type = BPF_PROG_TYPE_SOCK_OPS,
+		.config_disabled = !IS_BUILTIN(CONFIG_BPF_STREAM_PARSER),
 	},
 	{
 		"prevent map lookup in sockhash",
@@ -4655,6 +4661,7 @@ static struct bpf_test tests[] = {
 		.result = REJECT,
 		.errstr = "cannot pass map_type 18 into func bpf_map_lookup_elem",
 		.prog_type = BPF_PROG_TYPE_SOCK_OPS,
+		.config_disabled = !IS_BUILTIN(CONFIG_BPF_STREAM_PARSER),
 	},
 	{
 		"prevent map lookup in xskmap",
@@ -4671,6 +4678,7 @@ static struct bpf_test tests[] = {
 		.result = REJECT,
 		.errstr = "cannot pass map_type 17 into func bpf_map_lookup_elem",
 		.prog_type = BPF_PROG_TYPE_XDP,
+		.config_disabled = !IS_BUILTIN(CONFIG_XDP_SOCKETS),
 	},
 	{
 		"prevent map lookup in stack trace",
@@ -14537,6 +14545,13 @@ static int do_test(bool unpriv, unsigned int from, unsigned int to)
 	for (i = from; i < to; i++) {
 		struct bpf_test *test = &tests[i];
 
+		if (test->config_disabled) {
+			printf("#%d/u %s SKIP (missing required config)\n",
+			       i, test->descr);
+			skips++;
+			continue;
+		}
+
 		/* Program types that are not supported by non-root we
 		 * skip right away.
 		 */
-- 
2.20.0.rc2.403.gdbc3b29805-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ