Re: [PATCH v8 bpf-next 07/13] bpf: Add btf_struct_ids_match function
From: Jiri Olsa <hidden>
Date: 2020-07-29 18:55:16
Also in:
bpf
On Wed, Jul 29, 2020 at 10:51:26AM -0700, Andrii Nakryiko wrote:
On Wed, Jul 29, 2020 at 9:04 AM Jiri Olsa [off-list ref] wrote:quoted
On Tue, Jul 28, 2020 at 04:35:16PM -0700, Andrii Nakryiko wrote: SNIPquoted
quoted
diff --git a/include/linux/bpf.h b/include/linux/bpf.h index bae557ff2da8..c981e258fed3 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h@@ -1306,6 +1306,8 @@ int btf_struct_access(struct bpf_verifier_log *log, const struct btf_type *t, int off, int size, enum bpf_access_type atype, u32 *next_btf_id); +bool btf_struct_ids_match(struct bpf_verifier_log *log, + int off, u32 id, u32 mid); int btf_resolve_helper_id(struct bpf_verifier_log *log, const struct bpf_func_proto *fn, int);diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 1ab5fd5bf992..562d4453fad3 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c@@ -4140,6 +4140,35 @@ int btf_struct_access(struct bpf_verifier_log *log, return -EINVAL; } +bool btf_struct_ids_match(struct bpf_verifier_log *log, + int off, u32 id, u32 mid)just realized that if id == mid and off == 0, btf_struct_ids_match() will return false. Right now verifier is careful to not call btf_struct_ids_match in such case, but I wonder if it's better to make that (common) case also work?
right, also we should call btf_struct_ids_match when IDs are equal and off != 0, which we don't do now jirka