Re: [PATCH v3 bpf-next 01/11] bpf: Move the PTR_TO_BTF_ID check to check_reg_type()
From: Lorenz Bauer <hidden>
Date: 2020-09-23 09:48:04
Also in:
bpf
On Tue, 22 Sep 2020 at 19:38, Martin KaFai Lau [off-list ref] wrote:
On Tue, Sep 22, 2020 at 10:56:55AM +0100, Lorenz Bauer wrote:quoted
On Tue, 22 Sep 2020 at 08:04, Martin KaFai Lau [off-list ref] wrote:quoted
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 <redacted> --- 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.
Yeah, agreed. I've had a similar idea, but no time to implement it yet. -- Lorenz Bauer | Systems Engineer 6th Floor, County Hall/The Riverside Building, SE1 7PB, UK www.cloudflare.com