Re: [bpf-next PATCH v2 2/7] bpf: verifier, do explicit ALU32 bounds tracking

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

 



On Mon, Mar 30, 2020 at 02:36:39PM -0700, John Fastabend wrote:
> +static void __scalar64_min_max_lsh(struct bpf_reg_state *dst_reg,
> +				   u64 umin_val, u64 umax_val)
> +{
> +	/* Special case <<32 because it is a common compiler pattern to zero
> +	 * upper bits by doing <<32 s>>32. In this case if 32bit bounds are
> +	 * positive we know this shift will also be positive so we can track
> +	 * bounds correctly. Otherwise we lose all sign bit information except
> +	 * what we can pick up from var_off. Perhaps we can generalize this
> +	 * later to shifts of any length.
> +	 */
> +	if (umin_val == 32 && umax_val == 32 && dst_reg->s32_max_value >= 0)
> +		dst_reg->smax_value = (s64)dst_reg->s32_max_value << 32;
> +	else
> +		dst_reg->smax_value = S64_MAX;

I fixed up above comment to say 'sign extend' instead of 'zero upper bit' and
applied.
Thanks a ton for the awesome work.



[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