[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200922183805.l2fjw462hukiel4n@kafai-mbp.dhcp.thefacebook.com>
Date: Tue, 22 Sep 2020 11:38:05 -0700
From: Martin KaFai Lau <kafai@...com>
To: Lorenz Bauer <lmb@...udflare.com>
CC: bpf <bpf@...r.kernel.org>, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Kernel Team <kernel-team@...com>,
Networking <netdev@...r.kernel.org>
Subject: Re: [PATCH v3 bpf-next 01/11] bpf: Move the PTR_TO_BTF_ID check to
check_reg_type()
On Tue, Sep 22, 2020 at 10:56:55AM +0100, Lorenz Bauer wrote:
> On Tue, 22 Sep 2020 at 08:04, Martin KaFai Lau <kafai@...com> wrote:
> >
> > check_reg_type() checks whether a reg can be used as an arg of a
> > func_proto. For PTR_TO_BTF_ID, the check is actually not
> > completely done until the reg->btf_id is pointing to a
> > kernel struct that is acceptable by the func_proto.
> >
> > Thus, this patch moves the btf_id check into check_reg_type().
> > The compatible_reg_types[] usage is localized in check_reg_type() now.
> >
> > The "if (!btf_id) verbose(...); " is also removed since it won't happen.
> >
> > Signed-off-by: Martin KaFai Lau <kafai@...com>
> > ---
> > kernel/bpf/verifier.c | 65 +++++++++++++++++++++++--------------------
> > 1 file changed, 35 insertions(+), 30 deletions(-)
> >
> > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> > index 15ab889b0a3f..3ce61c412ea0 100644
> > --- a/kernel/bpf/verifier.c
> > +++ b/kernel/bpf/verifier.c
> > @@ -4028,20 +4028,29 @@ static const struct bpf_reg_types *compatible_reg_types[] = {
> > [__BPF_ARG_TYPE_MAX] = NULL,
> > };
> >
> > -static int check_reg_type(struct bpf_verifier_env *env, u32 regno,
> > - const struct bpf_reg_types *compatible)
> > +static int check_reg_type(struct bpf_verifier_env *env, u32 arg,
> > + enum bpf_arg_type arg_type,
> > + const struct bpf_func_proto *fn)
Yes. I think that works as good.
An idea for the mid term, I think this map helper's arg override logic
should belong to a new map_ops and this new map_ops can return the whole
"fn" instead of overriding on an arg-by-arg base.
Powered by blists - more mailing lists