Re: [PATCH bpf-next v4 03/10] bpf: Extend kfunc with PTR_TO_CTX, PTR_TO_MEM argument support

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

 



On Sun, Dec 19, 2021 at 07:47:22AM IST, Alexei Starovoitov wrote:
> On Fri, Dec 17, 2021 at 07:20:24AM +0530, Kumar Kartikeya Dwivedi wrote:
> >
> > +/* Returns true if struct is composed of scalars, 4 levels of nesting allowed */
> > +static bool __btf_type_is_scalar_struct(struct bpf_verifier_log *log,
> > +					const struct btf *btf,
> > +					const struct btf_type *t, int rec)
> > +{
> > +	const struct btf_type *member_type;
> > +	const struct btf_member *member;
> > +	u16 i;
> > +
> > +	if (rec == 4) {
> > +		bpf_log(log, "max struct nesting depth 4 exceeded\n");
> > +		return false;
> > +	}
>
> As Matteo found out that saves stack with gcc only,
> so I moved this check few lines below, just before recursive call.
>
> > +			if (is_kfunc) {
> > +				/* Permit pointer to mem, but only when argument
> > +				 * type is pointer to scalar, or struct composed
> > +				 * (recursively) of scalars.
> > +				 */
> > +				if (!btf_type_is_scalar(ref_t) && !__btf_type_is_scalar_struct(log, btf, ref_t, 0)) {
>
> ... and reformatted this line to fit screen width.
>
> ... and applied.
>

Thanks.

> Please add individual selftest for this feature
> (not tied into refcnted kfuncs and CT).

Ok, I'll add more in v5, but the second one in calls.c in patch 10/10 does check
it.

--
Kartikeya



[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