From: Andrii Nakryiko Date: Sun, 10 Jan 2021 07:03:40 +0000 (-0800) Subject: bpf: Allow empty module BTFs X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=bcc5e6162d66d44f7929f30fce032f95855fc8b4;p=linux.git bpf: Allow empty module BTFs Some modules don't declare any new types and end up with an empty BTF, containing only valid BTF header and no types or strings sections. This currently causes BTF validation error. There is nothing wrong with such BTF, so fix the issue by allowing module BTFs with no types or strings. Fixes: 36e68442d1af ("bpf: Load and verify kernel module BTFs") Reported-by: Christopher William Snowhill Signed-off-by: Andrii Nakryiko Signed-off-by: Daniel Borkmann Acked-by: Yonghong Song Link: https://lore.kernel.org/bpf/20210110070341.1380086-1-andrii@kernel.org --- diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 8d6bdb4f4d618..84a36ee4a4c20 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -4172,7 +4172,7 @@ static int btf_parse_hdr(struct btf_verifier_env *env) return -ENOTSUPP; } - if (btf_data_size == hdr->hdr_len) { + if (!btf->base_btf && btf_data_size == hdr->hdr_len) { btf_verifier_log(env, "No data"); return -EINVAL; }