summaryrefslogtreecommitdiffstats
path: root/kernel/bpf
diff options
context:
space:
mode:
authorYoshiki Komachi <komachi.yoshiki@gmail.com>2020-03-10 16:32:29 +0900
committerAlexei Starovoitov <ast@kernel.org>2020-03-10 10:00:41 -0700
commitda6c7faeb103c493e505e87643272f70be586635 (patch)
tree41c62e0d904f0ebaa19ce488df5552bccc485a89 /kernel/bpf
parent1d8006abaab4cb90f81add86e8d1bf9411add05a (diff)
downloadlinux-da6c7faeb103c493e505e87643272f70be586635.tar.gz
linux-da6c7faeb103c493e505e87643272f70be586635.tar.bz2
linux-da6c7faeb103c493e505e87643272f70be586635.zip
bpf/btf: Fix BTF verification of enum members in struct/union
btf_enum_check_member() was currently sure to recognize the size of "enum" type members in struct/union as the size of "int" even if its size was packed. This patch fixes BTF enum verification to use the correct size of member in BPF programs. Fixes: 179cde8cef7e ("bpf: btf: Check members of struct/union") Signed-off-by: Yoshiki Komachi <komachi.yoshiki@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/1583825550-18606-2-git-send-email-komachi.yoshiki@gmail.com
Diffstat (limited to 'kernel/bpf')
-rw-r--r--kernel/bpf/btf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 787140095e58..32ab9225026e 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -2418,7 +2418,7 @@ static int btf_enum_check_member(struct btf_verifier_env *env,
struct_size = struct_type->size;
bytes_offset = BITS_ROUNDDOWN_BYTES(struct_bits_off);
- if (struct_size - bytes_offset < sizeof(int)) {
+ if (struct_size - bytes_offset < member_type->size) {
btf_verifier_log_member(env, struct_type, member,
"Member exceeds struct_size");
return -EINVAL;