]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
libbpf: Fix BTF data layout checks and allow empty BTF
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 5 Nov 2020 04:33:57 +0000 (20:33 -0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Thu, 13 Jan 2022 17:42:26 +0000 (18:42 +0100)
commit6a50872dd2e64eab3d5203040ff16621ddbbc317
tree07353c3508a3f578a821403a22ca7638ebc17bc1
parentc981ac8d578800fec7e6f37b5b7a8e0d4c8aa3de
libbpf: Fix BTF data layout checks and allow empty BTF

BugLink: https://bugs.launchpad.net/bugs/1953387
[ Upstream commit d8123624506cd62730c9cd9c7672c698e462703d ]

Make data section layout checks stricter, disallowing overlap of types and
strings data.

Additionally, allow BTFs with no type data. There is nothing inherently wrong
with having BTF with no types (put potentially with some strings). This could
be a situation with kernel module BTFs, if module doesn't introduce any new
type information.

Also fix invalid offset alignment check for btf->hdr->type_off.

Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20201105043402.2530976-8-andrii@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
tools/lib/bpf/btf.c