aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCupertino Miranda <[email protected]>2024-05-06 15:18:46 +0100
committerAlexei Starovoitov <[email protected]>2024-05-06 17:09:11 -0700
commit138cc42c05d11fd5ee82ee1606d2c9823373a926 (patch)
tree383933f497a27b1046f720057b979d727e0d0516
parent0922c78f592c60e5a8fe6ab968479def124d4ff3 (diff)
bpf/verifier: improve XOR and OR range computation
Range for XOR and OR operators would not be attempted unless src_reg would resolve to a single value, i.e. a known constant value. This condition is unnecessary, and the following XOR/OR operator handling could compute a possible better range. Acked-by: Eduard Zingerman <[email protected]> Signed-off-by: Cupertino Miranda <[email protected] Acked-by: Eduard Zingerman <[email protected]> Cc: Yonghong Song <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: David Faust <[email protected]> Cc: Jose Marchesi <[email protected]> Cc: Elena Zannoni <[email protected]> Cc: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
-rw-r--r--kernel/bpf/verifier.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index bdaf0413bf06..1f6deb3e44c5 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -13900,12 +13900,12 @@ static bool is_safe_to_compute_dst_reg_range(struct bpf_insn *insn,
case BPF_ADD:
case BPF_SUB:
case BPF_AND:
+ case BPF_XOR:
+ case BPF_OR:
return true;
/* Compute range for the following only if the src_reg is const.
*/
- case BPF_XOR:
- case BPF_OR:
case BPF_MUL:
return src_is_const;