[dpdk-stable] patch 'bpf: allow self-xor operation' has been queued to stable release 20.11.4

Xueming Li xuemingl at nvidia.com
Wed Nov 10 07:30:56 CET 2021


Hi,

FYI, your patch has been queued to stable release 20.11.4

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/12/21. 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/steevenlee/dpdk

This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/97c39312a0e8972648e22b616fe1b3cbdde54ede

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 97c39312a0e8972648e22b616fe1b3cbdde54ede 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
Cc: Xueming Li <xuemingl at nvidia.com>

[ 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 7b1291b382..853279fee5 100644
--- a/lib/librte_bpf/bpf_validate.c
+++ b/lib/librte_bpf/bpf_validate.c
@@ -661,8 +661,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.33.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-11-10 14:17:09.576681326 +0800
+++ 0172-bpf-allow-self-xor-operation.patch	2021-11-10 14:17:01.984078497 +0800
@@ -1 +1 @@
-From 80da61198b6be66ab16964eb0944c79c0325c40e Mon Sep 17 00:00:00 2001
+From 97c39312a0e8972648e22b616fe1b3cbdde54ede Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 80da61198b6be66ab16964eb0944c79c0325c40e ]
@@ -15 +17,0 @@
-Cc: stable at dpdk.org
@@ -20 +22 @@
- lib/bpf/bpf_validate.c | 9 ++++++++-
+ lib/librte_bpf/bpf_validate.c | 9 ++++++++-
@@ -23 +25 @@
-diff --git a/lib/bpf/bpf_validate.c b/lib/bpf/bpf_validate.c
+diff --git a/lib/librte_bpf/bpf_validate.c b/lib/librte_bpf/bpf_validate.c
@@ -25,2 +27,2 @@
---- a/lib/bpf/bpf_validate.c
-+++ b/lib/bpf/bpf_validate.c
+--- a/lib/librte_bpf/bpf_validate.c
++++ b/lib/librte_bpf/bpf_validate.c


More information about the stable mailing list