Re: [PATCH bpf-next v2 04/15] bpf: Allow storing referenced kptr in map

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

 



On Sun, Mar 20, 2022 at 12:29:04AM +0530, Kumar Kartikeya Dwivedi wrote:
> > >
> > >  	if (is_release_function(func_id)) {
> > > -		err = release_reference(env, meta.ref_obj_id);
> > > +		err = -EINVAL;
> > > +		if (meta.ref_obj_id)
> > > +			err = release_reference(env, meta.ref_obj_id);
> > > +		/* Only bpf_kptr_xchg is a release function that accepts a
> > > +		 * possibly NULL reg, hence meta.ref_obj_id can only be unset
> > > +		 * for it.
> >
> > Could you rephrase the comment? I'm not following what it's trying to convey.
> >
> 
> All existing release helpers never take a NULL register, so their
> meta.ref_obj_id will never be unset, but bpf_kptr_xchg can, so it needs some
> special handling. In check_func_arg, when it jumps to skip_type_check label,
> reg->ref_obj_id won't be set for NULL value.

I still don't follow.
What do you mean 'unset meta.ref_obj_id' ?
It's either set or not.
meta->ref_obj_id will stay zero when arg == NULL.
Above 'if (meta.ref_obj_id)' makes sense.
But the code below with extra func_id check looks like defensive programming again.

> > > +		 */
> > > +		else if (func_id == BPF_FUNC_kptr_xchg)
> > > +			err = 0;



[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