libbpf: Validate that .BTF and .BTF.ext sections contain data
authorAndrii Nakryiko <andrii@kernel.org>
Wed, 3 Nov 2021 17:32:11 +0000 (10:32 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 3 Nov 2021 20:25:37 +0000 (13:25 -0700)
commit62554d52e71797eefa3fc15b54008038837bb2d4
treebca9ea3dbbbc86ca5a738ed497a31dbc0b32871e
parent88918dc12dc357a06d8d722a684617b1c87a4654
libbpf: Validate that .BTF and .BTF.ext sections contain data

.BTF and .BTF.ext ELF sections should have SHT_PROGBITS type and contain
data. If they are not, ELF is invalid or corrupted, so bail out.
Otherwise this can lead to data->d_buf being NULL and SIGSEGV later on.
Reported by oss-fuzz project.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20211103173213.1376990-4-andrii@kernel.org
tools/lib/bpf/libbpf.c