Skip to content

Commit a37a325

Browse files
lmbAlexei Starovoitov
authored andcommitted
bpf: btf: fix truncated last_member_type_id in btf_struct_resolve
When trying to finish resolving a struct member, btf_struct_resolve saves the member type id in a u16 temporary variable. This truncates the 32 bit type id value if it exceeds UINT16_MAX. As a result, structs that have members with type ids > UINT16_MAX and which need resolution will fail with a message like this: [67414] STRUCT ff_device size=120 vlen=12 effect_owners type_id=67434 bits_offset=960 Member exceeds struct_size Fix this by changing the type of last_member_type_id to u32. Fixes: a0791f0 ("bpf: fix BTF limits") Reviewed-by: Stanislav Fomichev <[email protected]> Signed-off-by: Lorenz Bauer <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 8a7d61b commit a37a325

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
@@ -3128,7 +3128,7 @@ static int btf_struct_resolve(struct btf_verifier_env *env,
31283128
if (v->next_member) {
31293129
const struct btf_type *last_member_type;
31303130
const struct btf_member *last_member;
3131-
u16 last_member_type_id;
3131+
u32 last_member_type_id;
31323132

31333133
last_member = btf_type_member(v->t) + v->next_member - 1;
31343134
last_member_type_id = last_member->type;

0 commit comments

Comments
 (0)