diff mbox series

[bpf,1/2] bpf: allow empty module BTFs

Message ID 20210110070341.1380086-1-andrii@kernel.org (mailing list archive)
State Accepted
Commit bcc5e6162d66d44f7929f30fce032f95855fc8b4
Delegated to: BPF
Headers show
Series [bpf,1/2] bpf: allow empty module BTFs | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf
netdev/subject_prefix success Link
netdev/cc_maintainers warning 7 maintainers not CCed: kafai@fb.com ast@kernel.org yhs@fb.com kpsingh@kernel.org songliubraving@fb.com john.fastabend@gmail.com gregkh@linuxfoundation.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 9 this patch: 9
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Andrii Nakryiko Jan. 10, 2021, 7:03 a.m. UTC
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(-)

Comments

Yonghong Song Jan. 11, 2021, 6:08 p.m. UTC | #1
On 1/9/21 11:03 PM, Andrii Nakryiko wrote:
> 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>

Acked-by: Yonghong Song <yhs@fb.com>
patchwork-bot+netdevbpf@kernel.org Jan. 12, 2021, 8:20 p.m. UTC | #2
Hello:

This series was applied to bpf/bpf.git (refs/heads/master):

On Sat, 9 Jan 2021 23:03:40 -0800 you wrote:
> 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>
> 
> [...]

Here is the summary with links:
  - [bpf,1/2] bpf: allow empty module BTFs
    https://git.kernel.org/bpf/bpf/c/bcc5e6162d66
  - [bpf,2/2] libbpf: allow loading empty BTFs
    https://git.kernel.org/bpf/bpf/c/b8d52264df85

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Christopher Snowhill Jan. 24, 2021, 10:27 a.m. UTC | #3
When is this being applied to an actual kernel? 5.11 is still quite broken without these two patches. Unless you're not using a vfat EFI partition, I guess.

On Tue, Jan 12, 2021, at 12:20 PM, patchwork-bot+netdevbpf@kernel.org wrote:
> Hello:
> 
> This series was applied to bpf/bpf.git (refs/heads/master):
> 
> On Sat, 9 Jan 2021 23:03:40 -0800 you wrote:
> > 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>
> > 
> > [...]
> 
> Here is the summary with links:
>   - [bpf,1/2] bpf: allow empty module BTFs
>     https://git.kernel.org/bpf/bpf/c/bcc5e6162d66
>   - [bpf,2/2] libbpf: allow loading empty BTFs
>     https://git.kernel.org/bpf/bpf/c/b8d52264df85
> 
> You are awesome, thank you!
> --
> Deet-doot-dot, I am a bot.
> https://korg.docs.kernel.org/patchwork/pwbot.html
> 
> 
>
Andrii Nakryiko Jan. 26, 2021, 1:26 a.m. UTC | #4
On Sun, Jan 24, 2021 at 2:28 AM Christopher William Snowhill
<chris@kode54.net> wrote:
>
> When is this being applied to an actual kernel? 5.11 is still quite broken without these two patches. Unless you're not using a vfat EFI partition, I guess.
>

It's in v5.11-rc5.

> On Tue, Jan 12, 2021, at 12:20 PM, patchwork-bot+netdevbpf@kernel.org wrote:
> > Hello:
> >
> > This series was applied to bpf/bpf.git (refs/heads/master):
> >
> > On Sat, 9 Jan 2021 23:03:40 -0800 you wrote:
> > > 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>
> > >
> > > [...]
> >
> > Here is the summary with links:
> >   - [bpf,1/2] bpf: allow empty module BTFs
> >     https://git.kernel.org/bpf/bpf/c/bcc5e6162d66
> >   - [bpf,2/2] libbpf: allow loading empty BTFs
> >     https://git.kernel.org/bpf/bpf/c/b8d52264df85
> >
> > You are awesome, thank you!
> > --
> > Deet-doot-dot, I am a bot.
> > https://korg.docs.kernel.org/patchwork/pwbot.html
> >
> >
> >
Christopher Snowhill Jan. 26, 2021, 2:17 a.m. UTC | #5
Aha, that was just released. Nice. I'll report this to the issue tracker where I had lodged the bpf patches for QoL use when testing rc4 and older.

On Mon, Jan 25, 2021, at 5:26 PM, Andrii Nakryiko wrote:
> On Sun, Jan 24, 2021 at 2:28 AM Christopher William Snowhill
> <chris@kode54.net> wrote:
> >
> > When is this being applied to an actual kernel? 5.11 is still quite broken without these two patches. Unless you're not using a vfat EFI partition, I guess.
> >
> 
> It's in v5.11-rc5.
> 
> > On Tue, Jan 12, 2021, at 12:20 PM, patchwork-bot+netdevbpf@kernel.org wrote:
> > > Hello:
> > >
> > > This series was applied to bpf/bpf.git (refs/heads/master):
> > >
> > > On Sat, 9 Jan 2021 23:03:40 -0800 you wrote:
> > > > 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>
> > > >
> > > > [...]
> > >
> > > Here is the summary with links:
> > >   - [bpf,1/2] bpf: allow empty module BTFs
> > >     https://git.kernel.org/bpf/bpf/c/bcc5e6162d66
> > >   - [bpf,2/2] libbpf: allow loading empty BTFs
> > >     https://git.kernel.org/bpf/bpf/c/b8d52264df85
> > >
> > > You are awesome, thank you!
> > > --
> > > Deet-doot-dot, I am a bot.
> > > https://korg.docs.kernel.org/patchwork/pwbot.html
> > >
> > >
> > >
>
diff mbox series

Patch

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;
 	}