Re: [RFC PATCH bpf-next/net v1 01/13] bpf: Tie dynptrs to referenced source objects

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

 



Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx> writes:

[...]

> @@ -818,22 +819,19 @@ static void invalidate_dynptr(struct bpf_verifier_env *env, struct bpf_func_stat
>  	state->stack[spi - 1].spilled_ptr.live |= REG_LIVE_WRITTEN;
>  }
>  
> -static int unmark_stack_slots_dynptr(struct bpf_verifier_env *env, struct bpf_reg_state *reg)
> +static int __unmark_stack_slots_dynptr(struct bpf_verifier_env *env, struct bpf_func_state *state,
> +				       int spi, bool slice)
>  {
> -	struct bpf_func_state *state = func(env, reg);
> -	int spi, ref_obj_id, i;
> +	u32 ref_obj_id;
> +	int i;
>  
> -	spi = dynptr_get_spi(env, reg);
> -	if (spi < 0)
> -		return spi;
> +	ref_obj_id = state->stack[spi].spilled_ptr.ref_obj_id;
>  
> -	if (!dynptr_type_refcounted(state->stack[spi].spilled_ptr.dynptr.type)) {
> +	if (!dynptr_type_refcounted(state->stack[spi].spilled_ptr.dynptr.type) && !ref_obj_id) {

If dynptr_type_refcounted is true, does this mean that ref_obj_id is set?
If it does, the check could be simplified to just `if (!ref_obj_id)`.

>  		invalidate_dynptr(env, state, spi);
>  		return 0;
>  	}
>  
> -	ref_obj_id = state->stack[spi].spilled_ptr.ref_obj_id;
> -
>  	/* If the dynptr has a ref_obj_id, then we need to invalidate
>  	 * two things:
>  	 *

[...]




[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