* [PATCH bpf] bpf: Fix modifier skipping logic
@ 2020-02-01 0:03 Alexei Starovoitov
2020-02-01 0:46 ` Yonghong Song
2020-02-03 23:10 ` Daniel Borkmann
0 siblings, 2 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2020-02-01 0:03 UTC (permalink / raw)
To: davem; +Cc: daniel, netdev, bpf, kernel-team
Fix the way modifiers are skipped while walking pointers. Otherwise second
level dereferences of 'const struct foo *' will be rejected by the verifier.
Fixes: 9e15db66136a ("bpf: Implement accurate raw_tp context access via BTF")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
kernel/bpf/btf.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index b7c1660fb594..a289f2915ba8 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -3931,6 +3931,7 @@ int btf_struct_access(struct bpf_verifier_log *log,
if (btf_type_is_ptr(mtype)) {
const struct btf_type *stype;
+ u32 id;
if (msize != size || off != moff) {
bpf_log(log,
@@ -3939,12 +3940,9 @@ int btf_struct_access(struct bpf_verifier_log *log,
return -EACCES;
}
- stype = btf_type_by_id(btf_vmlinux, mtype->type);
- /* skip modifiers */
- while (btf_type_is_modifier(stype))
- stype = btf_type_by_id(btf_vmlinux, stype->type);
+ stype = btf_type_skip_modifiers(btf_vmlinux, mtype->type, &id);
if (btf_type_is_struct(stype)) {
- *next_btf_id = mtype->type;
+ *next_btf_id = id;
return PTR_TO_BTF_ID;
}
}
--
2.23.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] bpf: Fix modifier skipping logic
2020-02-01 0:03 [PATCH bpf] bpf: Fix modifier skipping logic Alexei Starovoitov
@ 2020-02-01 0:46 ` Yonghong Song
2020-02-03 23:10 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Yonghong Song @ 2020-02-01 0:46 UTC (permalink / raw)
To: Alexei Starovoitov, davem; +Cc: daniel, netdev, bpf, kernel-team
On 1/31/20 4:03 PM, Alexei Starovoitov wrote:
> Fix the way modifiers are skipped while walking pointers. Otherwise second
> level dereferences of 'const struct foo *' will be rejected by the verifier.
>
> Fixes: 9e15db66136a ("bpf: Implement accurate raw_tp context access via BTF")
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] bpf: Fix modifier skipping logic
2020-02-01 0:03 [PATCH bpf] bpf: Fix modifier skipping logic Alexei Starovoitov
2020-02-01 0:46 ` Yonghong Song
@ 2020-02-03 23:10 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2020-02-03 23:10 UTC (permalink / raw)
To: Alexei Starovoitov, davem; +Cc: netdev, bpf, kernel-team
On 2/1/20 1:03 AM, Alexei Starovoitov wrote:
> Fix the way modifiers are skipped while walking pointers. Otherwise second
> level dereferences of 'const struct foo *' will be rejected by the verifier.
>
> Fixes: 9e15db66136a ("bpf: Implement accurate raw_tp context access via BTF")
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-03 23:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-01 0:03 [PATCH bpf] bpf: Fix modifier skipping logic Alexei Starovoitov
2020-02-01 0:46 ` Yonghong Song
2020-02-03 23:10 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).