Skip to content

Commit 657559d

Browse files
yosh1k104gregkh
authored andcommitted
bpf/btf: Fix BTF verification of enum members in struct/union
commit da6c7fa upstream. 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: 179cde8 ("bpf: btf: Check members of struct/union") Signed-off-by: Yoshiki Komachi <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 188aae1 commit 657559d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/bpf/btf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2309,7 +2309,7 @@ static int btf_enum_check_member(struct btf_verifier_env *env,
23092309

23102310
struct_size = struct_type->size;
23112311
bytes_offset = BITS_ROUNDDOWN_BYTES(struct_bits_off);
2312-
if (struct_size - bytes_offset < sizeof(int)) {
2312+
if (struct_size - bytes_offset < member_type->size) {
23132313
btf_verifier_log_member(env, struct_type, member,
23142314
"Member exceeds struct_size");
23152315
return -EINVAL;

0 commit comments

Comments
 (0)