提交 bcc5e616 编写于 作者: A Andrii Nakryiko 提交者: Daniel Borkmann

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: 36e68442 ("bpf: Load and verify kernel module BTFs")
Reported-by: NChristopher William Snowhill <chris@kode54.net>
Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
Acked-by: NYonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20210110070341.1380086-1-andrii@kernel.org
上级 4be34f3d
...@@ -4172,7 +4172,7 @@ static int btf_parse_hdr(struct btf_verifier_env *env) ...@@ -4172,7 +4172,7 @@ static int btf_parse_hdr(struct btf_verifier_env *env)
return -ENOTSUPP; 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"); btf_verifier_log(env, "No data");
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册