[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 19 Dec 2021 08:51:29 +0530
From: Kumar Kartikeya Dwivedi <memxor@...il.com>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: bpf@...r.kernel.org, netdev@...r.kernel.org,
netfilter-devel@...r.kernel.org,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
Maxim Mikityanskiy <maximmi@...dia.com>,
Pablo Neira Ayuso <pablo@...filter.org>,
Florian Westphal <fw@...len.de>,
Jesper Dangaard Brouer <brouer@...hat.com>,
Toke Høiland-Jørgensen <toke@...hat.com>
Subject: Re: [PATCH bpf-next v4 03/10] bpf: Extend kfunc with PTR_TO_CTX,
PTR_TO_MEM argument support
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
Powered by blists - more mailing lists