Skip to contentSkip to conversation

bpf: fix unreachable statement

PATCH Applied Min Hu (Connor) 3 participants 3 messages Apr 22, 2021 – May 5, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: fix unreachable statement

From: HongBo Zheng <[email protected]>

In function 'eval_jcc', judgment 'op == EBPF_JLT' occurs twice, as a result, the corresponding second statement cannot be accessed.

This patch fix this problem.

Fixes 8021917293d0 ("bpf: add extra validation for input BPF program")
---
 lib/librte_bpf/bpf_validate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_bpf/bpf_validate.c +1 -1
index 9214f15..7b1291b 100644
@@ -1115,7 +1115,7 @@ eval_jcc(struct bpf_verifier *bvf, const struct ebpf_insn *ins)
 		eval_jsgt_jsle(trd, trs, frd, frs);
 	else if (op == EBPF_JSLE)
 		eval_jsgt_jsle(frd, frs, trd, trs);
-	else if (op == EBPF_JLT)
+	else if (op == EBPF_JSLT)
 		eval_jslt_jsge(trd, trs, frd, frs);
 	else if (op == EBPF_JSGE)
 		eval_jslt_jsge(frd, frs, trd, trs);
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 24 lines

From: HongBo Zheng <[email protected]>

In function 'eval_jcc', judgment 'op == EBPF_JLT' occurs twice, as a result, the corresponding second statement cannot be accessed.

This patch fix this problem.

Fixes 8021917293d0 ("bpf: add extra validation for input BPF program")
---
 lib/librte_bpf/bpf_validate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_bpf/bpf_validate.c +0 -0
index 9214f15..7b1291b 100644

lib/librte_bpf/bpf_validate.c eval_jcc(struct bpf_verifier *bvf, const struct ebpf_insn *ins)

Quoted 9 lines
lib/librte_bpf/bpf_validate.c +1 -2
@@ -1115,7 +1115,7 @@ eval_jcc(struct bpf_verifier *bvf, const struct ebpf_insn *ins)
 		eval_jsgt_jsle(trd, trs, frd, frs);
 	else if (op == EBPF_JSLE)
 		eval_jsgt_jsle(frd, frs, trd, trs);
-	else if (op == EBPF_JLT)
+	else if (op == EBPF_JSLT)
 		eval_jslt_jsge(trd, trs, frd, frs);
 	else if (op == EBPF_JSGE)
 		eval_jslt_jsge(frd, frs, trd, trs);
--
Quoted 1 line

2.7.4

#2 lore raw

22/04/2021 13:23, Ananyev, Konstantin:

Quoted 8 lines
Quoted 8 lines

From: HongBo Zheng <[email protected]>

In function 'eval_jcc', judgment 'op == EBPF_JLT' occurs twice, as a result, the corresponding second statement cannot be accessed.

This patch fix this problem.

Quoted 7 lines
Quoted 5 lines
Fixes 8021917293d0 ("bpf: add extra validation for input BPF program")

Applied, thanks