Commit afbe1a5b authored by Yonghong Song's avatar Yonghong Song Committed by Alexei Starovoitov

bpf: remove never-hit branches in verifier adjust_scalar_min_max_vals

In verifier function adjust_scalar_min_max_vals,
when src_known is false and the opcode is BPF_LSH/BPF_RSH,
early return will happen in the function. So remove
the branch in handling BPF_LSH/BPF_RSH when src_known is false.
Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarYonghong Song <yhs@fb.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 849fa506
...@@ -2940,10 +2940,7 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, ...@@ -2940,10 +2940,7 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env,
dst_reg->umin_value <<= umin_val; dst_reg->umin_value <<= umin_val;
dst_reg->umax_value <<= umax_val; dst_reg->umax_value <<= umax_val;
} }
if (src_known) dst_reg->var_off = tnum_lshift(dst_reg->var_off, umin_val);
dst_reg->var_off = tnum_lshift(dst_reg->var_off, umin_val);
else
dst_reg->var_off = tnum_lshift(tnum_unknown, umin_val);
/* We may learn something more from the var_off */ /* We may learn something more from the var_off */
__update_reg_bounds(dst_reg); __update_reg_bounds(dst_reg);
break; break;
...@@ -2971,11 +2968,7 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env, ...@@ -2971,11 +2968,7 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env,
*/ */
dst_reg->smin_value = S64_MIN; dst_reg->smin_value = S64_MIN;
dst_reg->smax_value = S64_MAX; dst_reg->smax_value = S64_MAX;
if (src_known) dst_reg->var_off = tnum_rshift(dst_reg->var_off, umin_val);
dst_reg->var_off = tnum_rshift(dst_reg->var_off,
umin_val);
else
dst_reg->var_off = tnum_rshift(tnum_unknown, umin_val);
dst_reg->umin_value >>= umax_val; dst_reg->umin_value >>= umax_val;
dst_reg->umax_value >>= umin_val; dst_reg->umax_value >>= umin_val;
/* We may learn something more from the var_off */ /* We may learn something more from the var_off */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment