linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Edward Cree <ecree@solarflare.com>
To: <davem@davemloft.net>,
	Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	Alexei Starovoitov <ast@fb.com>,
	Daniel Borkmann <daniel@iogearbox.net>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	iovisor-dev <iovisor-dev@lists.iovisor.org>
Subject: [PATCH v4 net-next 02/13] nfp: change bpf verifier hooks to match new verifier data structures
Date: Thu, 3 Aug 2017 17:11:34 +0100	[thread overview]
Message-ID: <3d69276f-9f16-0c1a-4596-5c909abe08fc@solarflare.com> (raw)
In-Reply-To: <22441d84-0a11-5c00-2d2a-25e7dbafa6c2@solarflare.com>

Signed-off-by: Edward Cree <ecree@solarflare.com>
---
 drivers/net/ethernet/netronome/nfp/bpf/verifier.c | 24 +++++++++++++----------
 kernel/bpf/tnum.c                                 |  1 +
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/bpf/verifier.c b/drivers/net/ethernet/netronome/nfp/bpf/verifier.c
index d696ba4..5b783a9 100644
--- a/drivers/net/ethernet/netronome/nfp/bpf/verifier.c
+++ b/drivers/net/ethernet/netronome/nfp/bpf/verifier.c
@@ -79,28 +79,32 @@ nfp_bpf_check_exit(struct nfp_prog *nfp_prog,
 		   const struct bpf_verifier_env *env)
 {
 	const struct bpf_reg_state *reg0 = &env->cur_state.regs[0];
+	u64 imm;
 
 	if (nfp_prog->act == NN_ACT_XDP)
 		return 0;
 
-	if (reg0->type != CONST_IMM) {
-		pr_info("unsupported exit state: %d, imm: %llx\n",
-			reg0->type, reg0->imm);
+	if (!(reg0->type == SCALAR_VALUE && tnum_is_const(reg0->var_off))) {
+		char tn_buf[48];
+
+		tnum_strn(tn_buf, sizeof(tn_buf), reg0->var_off);
+		pr_info("unsupported exit state: %d, var_off: %s\n",
+			reg0->type, tn_buf);
 		return -EINVAL;
 	}
 
-	if (nfp_prog->act != NN_ACT_DIRECT &&
-	    reg0->imm != 0 && (reg0->imm & ~0U) != ~0U) {
+	imm = reg0->var_off.value;
+	if (nfp_prog->act != NN_ACT_DIRECT && imm != 0 && (imm & ~0U) != ~0U) {
 		pr_info("unsupported exit state: %d, imm: %llx\n",
-			reg0->type, reg0->imm);
+			reg0->type, imm);
 		return -EINVAL;
 	}
 
-	if (nfp_prog->act == NN_ACT_DIRECT && reg0->imm <= TC_ACT_REDIRECT &&
-	    reg0->imm != TC_ACT_SHOT && reg0->imm != TC_ACT_STOLEN &&
-	    reg0->imm != TC_ACT_QUEUED) {
+	if (nfp_prog->act == NN_ACT_DIRECT && imm <= TC_ACT_REDIRECT &&
+	    imm != TC_ACT_SHOT && imm != TC_ACT_STOLEN &&
+	    imm != TC_ACT_QUEUED) {
 		pr_info("unsupported exit state: %d, imm: %llx\n",
-			reg0->type, reg0->imm);
+			reg0->type, imm);
 		return -EINVAL;
 	}
 
diff --git a/kernel/bpf/tnum.c b/kernel/bpf/tnum.c
index 803bd0d..92eeeb1 100644
--- a/kernel/bpf/tnum.c
+++ b/kernel/bpf/tnum.c
@@ -141,6 +141,7 @@ int tnum_strn(char *str, size_t size, struct tnum a)
 {
 	return snprintf(str, size, "(%#llx; %#llx)", a.value, a.mask);
 }
+EXPORT_SYMBOL_GPL(tnum_strn);
 
 int tnum_sbin(char *str, size_t size, struct tnum a)
 {

  parent reply	other threads:[~2017-08-03 16:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-03 16:07 [PATCH v4 net-next 00/13] bpf: rewrite value tracking in verifier Edward Cree
2017-08-03 16:11 ` [PATCH v4 net-next 01/13] bpf/verifier: rework value tracking Edward Cree
2017-08-06 23:35   ` Daniel Borkmann
2017-08-07 12:39     ` Edward Cree
2017-08-03 16:11 ` Edward Cree [this message]
2017-08-07  4:01   ` [PATCH v4 net-next 02/13] nfp: change bpf verifier hooks to match new verifier data structures David Miller
2017-08-03 16:12 ` [PATCH v4 net-next 03/13] bpf/verifier: track signed and unsigned min/max values Edward Cree
2017-08-03 16:12 ` [PATCH v4 net-next 04/13] bpf/verifier: more concise register state logs for constant var_off Edward Cree
2017-08-03 16:12 ` [PATCH v4 net-next 05/13] selftests/bpf: change test_verifier expectations Edward Cree
2017-08-03 16:13 ` [PATCH v4 net-next 06/13] selftests/bpf: rewrite test_align Edward Cree
2017-08-03 16:13 ` [PATCH v4 net-next 07/13] selftests/bpf: add a test to test_align Edward Cree
2017-08-03 16:14 ` [PATCH v4 net-next 08/13] selftests/bpf: add test for bogus operations on pointers Edward Cree
2017-08-03 16:14 ` [PATCH v4 net-next 09/13] selftests/bpf: don't try to access past MAX_PACKET_OFF in test_verifier Edward Cree
2017-08-03 16:15 ` [PATCH v4 net-next 10/13] selftests/bpf: add tests for subtraction & negative numbers Edward Cree
2017-08-03 16:15 ` [PATCH v4 net-next 11/13] selftests/bpf: variable offset negative tests Edward Cree
2017-08-03 16:15 ` [PATCH v4 net-next 12/13] Documentation: describe the new eBPF verifier value tracking behaviour Edward Cree
2017-08-03 16:16 ` [PATCH v4 net-next 13/13] bpf/verifier: increase complexity limit to 128k Edward Cree

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=3d69276f-9f16-0c1a-4596-5c909abe08fc@solarflare.com \
    --to=ecree@solarflare.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=ast@fb.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=iovisor-dev@lists.iovisor.org \
    --cc=linux-kernel@vger.kernel.org \
    --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).