patch 'bpf: allow self-xor operation' has been queued to stable release 19.11.11

christian.ehrhardt at canonical.com christian.ehrhardt at canonical.com
Tue Nov 30 17:34:56 CET 2021


Hi,

FYI, your patch has been queued to stable release 19.11.11

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before December 10th 2021. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/cpaelzer/dpdk-stable-queue

This queued commit can be viewed at:
https://github.com/cpaelzer/dpdk-stable-queue/commit/fb117f17e22d0cb862884798348f4232f6a2c270

Thanks.

Christian Ehrhardt <christian.ehrhardt at canonical.com>

---
>From fb117f17e22d0cb862884798348f4232f6a2c270 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen at networkplumber.org>
Date: Wed, 20 Oct 2021 14:42:27 -0700
Subject: [PATCH] bpf: allow self-xor operation

[ upstream commit 80da61198b6be66ab16964eb0944c79c0325c40e ]

Some BPF programs may use XOR of a register with itself
as a way to zero register in one instruction.
The BPF filter converter generates this in the prolog
to the generated code.

The BPF validator would not allow this because the value of
register was undefined. But after this operation it always zero.

Fixes: 8021917293d0 ("bpf: add extra validation for input BPF program")

Acked-by: Konstantin Ananyev <konstantin.ananyev at intel.com>
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 lib/librte_bpf/bpf_validate.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/librte_bpf/bpf_validate.c b/lib/librte_bpf/bpf_validate.c
index 21ee106649..a7c588a92a 100644
--- a/lib/librte_bpf/bpf_validate.c
+++ b/lib/librte_bpf/bpf_validate.c
@@ -621,8 +621,15 @@ eval_alu(struct bpf_verifier *bvf, const struct ebpf_insn *ins)
 
 	op = BPF_OP(ins->code);
 
+	/* Allow self-xor as way to zero register */
+	if (op == BPF_XOR && BPF_SRC(ins->code) == BPF_X &&
+	    ins->src_reg == ins->dst_reg) {
+		eval_fill_imm(&rs, UINT64_MAX, 0);
+		eval_fill_imm(rd, UINT64_MAX, 0);
+	}
+
 	err = eval_defined((op != EBPF_MOV) ? rd : NULL,
-			(op != BPF_NEG) ? &rs : NULL);
+			   (op != BPF_NEG) ? &rs : NULL);
 	if (err != NULL)
 		return err;
 
-- 
2.34.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-11-30 16:50:11.269763275 +0100
+++ 0092-bpf-allow-self-xor-operation.patch	2021-11-30 16:50:05.890874264 +0100
@@ -1 +1 @@
-From 80da61198b6be66ab16964eb0944c79c0325c40e Mon Sep 17 00:00:00 2001
+From fb117f17e22d0cb862884798348f4232f6a2c270 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 80da61198b6be66ab16964eb0944c79c0325c40e ]
+
@@ -15 +16,0 @@
-Cc: stable at dpdk.org
@@ -20 +21 @@
- lib/bpf/bpf_validate.c | 9 ++++++++-
+ lib/librte_bpf/bpf_validate.c | 9 ++++++++-
@@ -23,5 +24,5 @@
-diff --git a/lib/bpf/bpf_validate.c b/lib/bpf/bpf_validate.c
-index 7b1291b382..853279fee5 100644
---- a/lib/bpf/bpf_validate.c
-+++ b/lib/bpf/bpf_validate.c
-@@ -661,8 +661,15 @@ eval_alu(struct bpf_verifier *bvf, const struct ebpf_insn *ins)
+diff --git a/lib/librte_bpf/bpf_validate.c b/lib/librte_bpf/bpf_validate.c
+index 21ee106649..a7c588a92a 100644
+--- a/lib/librte_bpf/bpf_validate.c
++++ b/lib/librte_bpf/bpf_validate.c
+@@ -621,8 +621,15 @@ eval_alu(struct bpf_verifier *bvf, const struct ebpf_insn *ins)


More information about the stable mailing list