netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Borkmann <dborkman@redhat.com>
To: davem@davemloft.net
Cc: ast@plumgrid.com, netdev@vger.kernel.org
Subject: [PATCH net-next 2/4] net: filter: add test for loading SKF_AD_OFF limits
Date: Thu, 29 May 2014 10:22:49 +0200	[thread overview]
Message-ID: <1401351771-5367-3-git-send-email-dborkman@redhat.com> (raw)
In-Reply-To: <1401351771-5367-1-git-send-email-dborkman@redhat.com>

This check tests that overloading BPF_LD | BPF_ABS with an
always invalid BPF extension, that is SKF_AD_MAX, fails to
make sure classic BPF behaviour is correct in filter checker.

Also, we add a test for loading at packet offset SKF_AD_OFF-1
which should pass the filter, but later on fail during runtime.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
---
 lib/test_bpf.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 2d0a0d1..f8d2b2a 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -1655,6 +1655,28 @@ static struct bpf_test tests[] = {
 		{ },
 		{ { 0, 0x2a5a5e5 } },
 	},
+	{
+		"check: SKF_AD_MAX",
+		.u.insns = {
+			BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
+				 SKF_AD_OFF + SKF_AD_MAX),
+			BPF_STMT(BPF_RET | BPF_A, 0),
+		},
+		CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
+		{ },
+		{ },
+	},
+	{	/* Passes checker but fails during runtime. */
+		"LD [SKF_AD_OFF-1]",
+		.u.insns = {
+			BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
+				 SKF_AD_OFF - 1),
+			BPF_STMT(BPF_RET | BPF_K, 1),
+		},
+		CLASSIC,
+		{ },
+		{ { 1, 0 } },
+	},
 };
 
 static struct net_device dev;
-- 
1.7.11.7

  parent reply	other threads:[~2014-05-29  8:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-29  8:22 [PATCH net-next 0/4] BPF + test suite updates Daniel Borkmann
2014-05-29  8:22 ` [PATCH net-next 1/4] net: filter: add slot overlapping test with fully filled M[] Daniel Borkmann
2014-05-30 22:54   ` Chema Gonzalez
2014-05-30 23:41     ` Alexei Starovoitov
2014-05-29  8:22 ` Daniel Borkmann [this message]
2014-05-29  8:22 ` [PATCH net-next 3/4] net: filter: get rid of BPF_S_* enum Daniel Borkmann
2014-05-30 23:22   ` Chema Gonzalez
2014-05-30 23:30   ` Alexei Starovoitov
2014-05-29  8:22 ` [PATCH net-next 4/4] net: filter: improve filter block macros Daniel Borkmann
2014-06-02  5:18 ` [PATCH net-next 0/4] BPF + test suite updates David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1401351771-5367-3-git-send-email-dborkman@redhat.com \
    --to=dborkman@redhat.com \
    --cc=ast@plumgrid.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).