Re: [PATCH bpf v1 1/5] bpf: Fix kfunc register offset check for PTR_TO_BTF_ID

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

 



On Sat, Feb 19, 2022 at 05:07:40PM +0530, Kumar Kartikeya Dwivedi wrote:
>  
> +/* Caller ensures reg->type does not have PTR_MAYBE_NULL */
> +int check_func_arg_reg_off(struct bpf_verifier_env *env,
> +			   const struct bpf_reg_state *reg, int regno,
> +			   bool arg_alloc_mem)
> +{
> +	enum bpf_reg_type type = reg->type;
> +	int err;
> +
> +	WARN_ON_ONCE(type & PTR_MAYBE_NULL);

So the warn was added and made things more difficult and check had to be moved
into check_mem_reg to clear that flag?
Why add that warn in the first place then?
The logic get convoluted because of that.

> +	if (reg->off < 0) {
> +		verbose(env, "negative offset %s ptr R%d off=%d disallowed\n",
> +			reg_type_str(env, reg->type), regno, reg->off);
> +		return -EACCES;
> +	}

Out of the whole patch this part is useful. The rest seems to dealing
with self inflicted pain.
Just call check_ptr_off_reg() for kfunc ?
The patch seems to be doing several things at once. Please split.



[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