]> git.baikalelectronics.ru Git - 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)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 6 Nov 2020 02:37:30 +0000 (18:37 -0800)
commit3de9600112a27e05ed710ce813e2f616960945fe
treecec646e60868d1711d367bfe49038546b6b650b0
parent8021daf3eaec6e5e7c6d53988295fddd3803621f
libbpf: Fix BTF data layout checks and allow empty BTF

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: 7713ed396b94 ("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
tools/lib/bpf/btf.c