Skip to content

Commit

Permalink
libbpf: Allow loading empty BTFs
Browse files Browse the repository at this point in the history
Empty BTFs do come up (e.g., simple kernel modules with no new types and
strings, compared to the vmlinux BTF) and there is nothing technically wrong
with them. So remove unnecessary check preventing loading empty BTFs.

Fixes: d812362 ("libbpf: Fix BTF data layout checks and allow empty BTF")
Reported-by: Christopher William Snowhill <chris@kode54.net>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210110070341.1380086-2-andrii@kernel.org
  • Loading branch information
Andrii Nakryiko authored and Daniel Borkmann committed Jan 12, 2021
1 parent bcc5e61 commit b8d5226
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions tools/lib/bpf/btf.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,6 @@ static int btf_parse_hdr(struct btf *btf)
}

meta_left = btf->raw_size - sizeof(*hdr);
if (!meta_left) {
pr_debug("BTF has no data\n");
return -EINVAL;
}

if (meta_left < hdr->str_off + hdr->str_len) {
pr_debug("Invalid BTF total size:%u\n", btf->raw_size);
return -EINVAL;
Expand Down

0 comments on commit b8d5226

Please sign in to comment.