bpf: Fix propagation of 32 bit unsigned bounds from 64 bit bounds
[linux-2.6-microblaze.git] / kernel / bpf / verifier.c
index 637462e..9145f88 100644 (file)
@@ -1398,9 +1398,7 @@ static bool __reg64_bound_s32(s64 a)
 
 static bool __reg64_bound_u32(u64 a)
 {
-       if (a > U32_MIN && a < U32_MAX)
-               return true;
-       return false;
+       return a > U32_MIN && a < U32_MAX;
 }
 
 static void __reg_combine_64_into_32(struct bpf_reg_state *reg)
@@ -1411,10 +1409,10 @@ static void __reg_combine_64_into_32(struct bpf_reg_state *reg)
                reg->s32_min_value = (s32)reg->smin_value;
                reg->s32_max_value = (s32)reg->smax_value;
        }
-       if (__reg64_bound_u32(reg->umin_value))
+       if (__reg64_bound_u32(reg->umin_value) && __reg64_bound_u32(reg->umax_value)) {
                reg->u32_min_value = (u32)reg->umin_value;
-       if (__reg64_bound_u32(reg->umax_value))
                reg->u32_max_value = (u32)reg->umax_value;
+       }
 
        /* Intersecting with the old var_off might have improved our bounds
         * slightly.  e.g. if umax was 0x7f...f and var_off was (0; 0xf...fc),