All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC bpf-next 3/3] bpf: Apply F_LOAD_WITH_ANY_ALIGNMENT to ACCEPT test cases too.
@ 2018-11-29  7:41 David Miller
  0 siblings, 0 replies; only message in thread
From: David Miller @ 2018-11-29  7:41 UTC (permalink / raw)
  To: daniel; +Cc: ast, netdev


If a testcase has alignment problems but is expected to be ACCEPT,
verify it using F_LOAD_WITH_ANY_ALIGNMENT however to not try to
execute it.

In this way folks on inefficient unaligned access architectures
can more fully regression test the verifier.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 tools/testing/selftests/bpf/test_verifier.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index 1a68863..8191f3e 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -3919,6 +3919,7 @@ static struct bpf_test tests[] = {
 		},
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
 		.result = ACCEPT,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"direct packet access: test21 (x += pkt_ptr, 2)",
@@ -3944,6 +3945,7 @@ static struct bpf_test tests[] = {
 		},
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
 		.result = ACCEPT,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"direct packet access: test22 (x += pkt_ptr, 3)",
@@ -3974,6 +3976,7 @@ static struct bpf_test tests[] = {
 		},
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
 		.result = ACCEPT,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"direct packet access: test23 (x += pkt_ptr, 4)",
@@ -4026,6 +4029,7 @@ static struct bpf_test tests[] = {
 		},
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
 		.result = ACCEPT,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"direct packet access: test25 (marking on <, good access)",
@@ -7733,6 +7737,7 @@ static struct bpf_test tests[] = {
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
 		.retval = 0 /* csum_diff of 64-byte packet */,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"helper access to variable memory: size = 0 not allowed on NULL (!ARG_PTR_TO_MEM_OR_NULL)",
@@ -9695,6 +9700,7 @@ static struct bpf_test tests[] = {
 		},
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_XDP,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"XDP pkt read, pkt_data' > pkt_end, bad access 1",
@@ -9866,6 +9872,7 @@ static struct bpf_test tests[] = {
 		},
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_XDP,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"XDP pkt read, pkt_end < pkt_data', bad access 1",
@@ -9978,6 +9985,7 @@ static struct bpf_test tests[] = {
 		},
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_XDP,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"XDP pkt read, pkt_end >= pkt_data', bad access 1",
@@ -10035,6 +10043,7 @@ static struct bpf_test tests[] = {
 		},
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_XDP,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"XDP pkt read, pkt_data' <= pkt_end, bad access 1",
@@ -10147,6 +10156,7 @@ static struct bpf_test tests[] = {
 		},
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_XDP,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"XDP pkt read, pkt_meta' > pkt_data, bad access 1",
@@ -10318,6 +10328,7 @@ static struct bpf_test tests[] = {
 		},
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_XDP,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"XDP pkt read, pkt_data < pkt_meta', bad access 1",
@@ -10430,6 +10441,7 @@ static struct bpf_test tests[] = {
 		},
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_XDP,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"XDP pkt read, pkt_data >= pkt_meta', bad access 1",
@@ -10487,6 +10499,7 @@ static struct bpf_test tests[] = {
 		},
 		.result = ACCEPT,
 		.prog_type = BPF_PROG_TYPE_XDP,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"XDP pkt read, pkt_meta' <= pkt_data, bad access 1",
@@ -12406,6 +12419,7 @@ static struct bpf_test tests[] = {
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
 		.result = ACCEPT,
 		.retval = 1,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"calls: pkt_ptr spill into caller stack 4",
@@ -12440,6 +12454,7 @@ static struct bpf_test tests[] = {
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
 		.result = ACCEPT,
 		.retval = 1,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"calls: pkt_ptr spill into caller stack 5",
@@ -12585,6 +12600,7 @@ static struct bpf_test tests[] = {
 		},
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
 		.result = ACCEPT,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"calls: pkt_ptr spill into caller stack 9",
@@ -13508,6 +13524,7 @@ static struct bpf_test tests[] = {
 		},
 		.prog_type = BPF_PROG_TYPE_SCHED_CLS,
 		.result = ACCEPT,
+		.flags = F_LOAD_WITH_ANY_ALIGNMENT,
 	},
 	{
 		"reference tracking in call: free reference in subprog",
@@ -14347,6 +14364,11 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
 			       strerror(errno));
 			goto fail_log;
 		}
+#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
+		if (fd_prog >= 0 &&
+		    (test->flags & F_LOAD_WITH_ANY_ALIGNMENT))
+			goto test_ok;
+#endif
 	} else {
 		if (fd_prog >= 0) {
 			printf("FAIL\nUnexpected success to load!\n");
@@ -14380,6 +14402,9 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
 			goto fail_log;
 		}
 	}
+#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
+test_ok:
+#endif
 	(*passes)++;
 	printf("OK%s\n", reject_from_alignment ?
 	       " (NOTE: reject due to unknown alignment)" : "");
-- 
2.1.2.532.g19b5d50

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-11-29 18:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-29  7:41 [PATCH RFC bpf-next 3/3] bpf: Apply F_LOAD_WITH_ANY_ALIGNMENT to ACCEPT test cases too David Miller

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.