]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: btf: fix truncated last_member_type_id in btf_struct_resolve
authorLorenz Bauer <oss@lmb.io>
Sat, 10 Sep 2022 11:01:20 +0000 (11:01 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 11:22:24 +0000 (13:22 +0200)
commitcd3ec1a5d83b1aa0da1892a1de77b8278dc27814
tree527fd5484f0add0f7e550a7d063c2e2d2ad6e08e
parent0837d8ee0d43d769b07212709f43512206b36038
bpf: btf: fix truncated last_member_type_id in btf_struct_resolve

[ Upstream commit 5ce884ac61d4b0e271694ec041edd8dad8dc6dff ]

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: 33fe8e54309d ("bpf: fix BTF limits")
Reviewed-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Lorenz Bauer <oss@lmb.io>
Link: https://lore.kernel.org/r/20220910110120.339242-1-oss@lmb.io
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/btf.c