]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
libbpf: Fix overflow in BTF sanity checks
authorAndrii Nakryiko <andrii@kernel.org>
Sat, 23 Oct 2021 00:31:56 +0000 (17:31 -0700)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 7 Dec 2021 06:33:07 +0000 (07:33 +0100)
commit27c7c035612e7d360be1d50e177de4b2b9f55ffd
tree8dd732ae8999bdabb12a91da2430132d7272eaf0
parentc3da89a0d6d772ef1086e192c2a8b41cae6832e6
libbpf: Fix overflow in BTF sanity checks

BugLink: https://bugs.launchpad.net/bugs/1951822
[ Upstream commit 5245dafe3d49efba4d3285cf27ee1cc1eeafafc6 ]

btf_header's str_off+str_len or type_off+type_len can overflow as they
are u32s. This will lead to bypassing the sanity checks during BTF
parsing, resulting in crashes afterwards. Fix by using 64-bit signed
integers for comparison.

Fixes: d8123624506c ("libbpf: Fix BTF data layout checks and allow empty BTF")
Reported-by: Evgeny Vereshchagin <evvers@ya.ru>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20211023003157.726961-1-andrii@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
tools/lib/bpf/btf.c