bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf 1/2] bpf: allow empty module BTFs
@ 2021-01-10  7:03 Andrii Nakryiko
  2021-01-10  7:03 ` [PATCH bpf 2/2] libbpf: allow loading empty BTFs Andrii Nakryiko
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Andrii Nakryiko @ 2021-01-10  7:03 UTC (permalink / raw)
  To: bpf, netdev, ast, daniel
  Cc: andrii, kernel-team, Christopher William Snowhill

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.

Reported-by: Christopher William Snowhill <chris@kode54.net>
Fixes: 36e68442d1af ("bpf: Load and verify kernel module BTFs")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
 kernel/bpf/btf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 8d6bdb4f4d61..84a36ee4a4c2 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;
 	}
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-01-26  5:38 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-10  7:03 [PATCH bpf 1/2] bpf: allow empty module BTFs Andrii Nakryiko
2021-01-10  7:03 ` [PATCH bpf 2/2] libbpf: allow loading empty BTFs Andrii Nakryiko
2021-01-11 18:13   ` Yonghong Song
2021-01-11 20:51     ` Andrii Nakryiko
2021-01-12  1:15       ` Yonghong Song
2021-01-12  6:41         ` Andrii Nakryiko
2021-01-12 20:17           ` Daniel Borkmann
2021-01-12 20:26             ` Andrii Nakryiko
2021-01-11 18:08 ` [PATCH bpf 1/2] bpf: allow empty module BTFs Yonghong Song
2021-01-12 20:20 ` patchwork-bot+netdevbpf
2021-01-24 10:27   ` Christopher William Snowhill
2021-01-26  1:26     ` Andrii Nakryiko
2021-01-26  2:17       ` Christopher William Snowhill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).