* [PATCH bpf 1/2] bpf: fix BTF verification of enums
2019-09-17 17:45 [PATCH bpf 0/2] bpf: BTF fixes Alexei Starovoitov
@ 2019-09-17 17:45 ` Alexei Starovoitov
2019-09-17 17:45 ` [PATCH bpf 2/2] bpf: fix BTF limits Alexei Starovoitov
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Alexei Starovoitov @ 2019-09-17 17:45 UTC (permalink / raw)
To: davem; +Cc: daniel, netdev, bpf, kernel-team
vmlinux BTF has enums that are 8 byte and 1 byte in size.
2 byte enum is a valid construct as well.
Fix BTF enum verification to accept those sizes.
Fixes: 69b693f0aefa ("bpf: btf: Introduce BPF Type Format (BTF)")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Martin KaFai Lau <kafai@fb.com>
---
kernel/bpf/btf.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index adb3adcebe3c..722d38e543e9 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -2377,9 +2377,8 @@ static s32 btf_enum_check_meta(struct btf_verifier_env *env,
return -EINVAL;
}
- if (t->size != sizeof(int)) {
- btf_verifier_log_type(env, t, "Expected size:%zu",
- sizeof(int));
+ if (t->size > 8 || !is_power_of_2(t->size)) {
+ btf_verifier_log_type(env, t, "Unexpected size");
return -EINVAL;
}
--
2.20.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH bpf 2/2] bpf: fix BTF limits
2019-09-17 17:45 [PATCH bpf 0/2] bpf: BTF fixes Alexei Starovoitov
2019-09-17 17:45 ` [PATCH bpf 1/2] bpf: fix BTF verification of enums Alexei Starovoitov
@ 2019-09-17 17:45 ` Alexei Starovoitov
2019-09-17 19:35 ` [PATCH bpf 0/2] bpf: BTF fixes Andrii Nakryiko
2019-09-19 12:33 ` Daniel Borkmann
3 siblings, 0 replies; 5+ messages in thread
From: Alexei Starovoitov @ 2019-09-17 17:45 UTC (permalink / raw)
To: davem; +Cc: daniel, netdev, bpf, kernel-team
vmlinux BTF has more than 64k types.
Its string section is also at the offset larger than 64k.
Adjust both limits to make in-kernel BTF verifier successfully parse in-kernel BTF.
Fixes: 69b693f0aefa ("bpf: btf: Introduce BPF Type Format (BTF)")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Martin KaFai Lau <kafai@fb.com>
---
include/uapi/linux/btf.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/btf.h b/include/uapi/linux/btf.h
index 63ae4a39e58b..c02dec97e1ce 100644
--- a/include/uapi/linux/btf.h
+++ b/include/uapi/linux/btf.h
@@ -22,9 +22,9 @@ struct btf_header {
};
/* Max # of type identifier */
-#define BTF_MAX_TYPE 0x0000ffff
+#define BTF_MAX_TYPE 0x000fffff
/* Max offset into the string section */
-#define BTF_MAX_NAME_OFFSET 0x0000ffff
+#define BTF_MAX_NAME_OFFSET 0x00ffffff
/* Max # of struct/union/enum members or func args */
#define BTF_MAX_VLEN 0xffff
--
2.20.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH bpf 0/2] bpf: BTF fixes
2019-09-17 17:45 [PATCH bpf 0/2] bpf: BTF fixes Alexei Starovoitov
2019-09-17 17:45 ` [PATCH bpf 1/2] bpf: fix BTF verification of enums Alexei Starovoitov
2019-09-17 17:45 ` [PATCH bpf 2/2] bpf: fix BTF limits Alexei Starovoitov
@ 2019-09-17 19:35 ` Andrii Nakryiko
2019-09-19 12:33 ` Daniel Borkmann
3 siblings, 0 replies; 5+ messages in thread
From: Andrii Nakryiko @ 2019-09-17 19:35 UTC (permalink / raw)
To: Alexei Starovoitov
Cc: David S. Miller, Daniel Borkmann, Networking, bpf, Kernel Team
On Tue, Sep 17, 2019 at 12:27 PM Alexei Starovoitov <ast@kernel.org> wrote:
>
> Two trivial BTF fixes.
>
> Alexei Starovoitov (2):
> bpf: fix BTF verification of enums
> bpf: fix BTF limits
>
> include/uapi/linux/btf.h | 4 ++--
> kernel/bpf/btf.c | 5 ++---
> 2 files changed, 4 insertions(+), 5 deletions(-)
>
> --
> 2.20.0
>
For the series:
Acked-by: Andrii Nakryiko <andriin@fb.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH bpf 0/2] bpf: BTF fixes
2019-09-17 17:45 [PATCH bpf 0/2] bpf: BTF fixes Alexei Starovoitov
` (2 preceding siblings ...)
2019-09-17 19:35 ` [PATCH bpf 0/2] bpf: BTF fixes Andrii Nakryiko
@ 2019-09-19 12:33 ` Daniel Borkmann
3 siblings, 0 replies; 5+ messages in thread
From: Daniel Borkmann @ 2019-09-19 12:33 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: davem, netdev, bpf, kernel-team
On Tue, Sep 17, 2019 at 10:45:36AM -0700, Alexei Starovoitov wrote:
> Two trivial BTF fixes.
>
> Alexei Starovoitov (2):
> bpf: fix BTF verification of enums
> bpf: fix BTF limits
>
> include/uapi/linux/btf.h | 4 ++--
> kernel/bpf/btf.c | 5 ++---
> 2 files changed, 4 insertions(+), 5 deletions(-)
Applied, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread