[PATCH] bpf: clean up unnecessary conditional judgments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jackie Liu <liuyun01@xxxxxxxxxx>

s32 is always true regardless of the values of its operands. let's
cleanup.

Fixes: e572ff80f05c ("bpf: Make 32->64 bounds propagation slightly more	robust")
Reported-by: k2ci <kernel-bot@xxxxxxxxxx>
Signed-off-by: Jackie Liu <liuyun01@xxxxxxxxxx>
---
 kernel/bpf/verifier.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index b532f1058d35..43812ee58304 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -1366,11 +1366,6 @@ static void __reg_bound_offset(struct bpf_reg_state *reg)
 	reg->var_off = tnum_or(tnum_clear_subreg(var64_off), var32_off);
 }
 
-static bool __reg32_bound_s64(s32 a)
-{
-	return a >= 0 && a <= S32_MAX;
-}
-
 static void __reg_assign_32_into_64(struct bpf_reg_state *reg)
 {
 	reg->umin_value = reg->u32_min_value;
@@ -1380,8 +1375,7 @@ static void __reg_assign_32_into_64(struct bpf_reg_state *reg)
 	 * be positive otherwise set to worse case bounds and refine later
 	 * from tnum.
 	 */
-	if (__reg32_bound_s64(reg->s32_min_value) &&
-	    __reg32_bound_s64(reg->s32_max_value)) {
+	if (reg->s32_min_value >= 0 && reg->s32_max_value >= 0) {
 		reg->smin_value = reg->s32_min_value;
 		reg->smax_value = reg->s32_max_value;
 	} else {
-- 
2.25.1




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux