2022-04-04 14:32:53

by Yuntao Wang

[permalink] [raw]
Subject: [PATCH bpf-next v3] libbpf: Don't return -EINVAL if hdr_len < offsetofend(core_relo_len)

Since core relos is an optional part of the .BTF.ext ELF section, we should
skip parsing it instead of returning -EINVAL if header size is less than
offsetofend(struct btf_ext_header, core_relo_len).

Signed-off-by: Yuntao Wang <[email protected]>
---
v1 -> v2: skip core relos if hdr_len < offsetofend(core_relo_len)
v2 -> v3: fix comment style

tools/lib/bpf/btf.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 1383e26c5d1f..d124e9e533f0 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -2826,10 +2826,8 @@ struct btf_ext *btf_ext__new(const __u8 *data, __u32 size)
if (err)
goto done;

- if (btf_ext->hdr->hdr_len < offsetofend(struct btf_ext_header, core_relo_len)) {
- err = -EINVAL;
- goto done;
- }
+ if (btf_ext->hdr->hdr_len < offsetofend(struct btf_ext_header, core_relo_len))
+ goto done; /* skip core relos parsing */

err = btf_ext_setup_core_relos(btf_ext);
if (err)
--
2.35.1


2022-04-05 00:20:18

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH bpf-next v3] libbpf: Don't return -EINVAL if hdr_len < offsetofend(core_relo_len)

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <[email protected]>:

On Mon, 4 Apr 2022 08:53:20 +0800 you wrote:
> Since core relos is an optional part of the .BTF.ext ELF section, we should
> skip parsing it instead of returning -EINVAL if header size is less than
> offsetofend(struct btf_ext_header, core_relo_len).
>
> Signed-off-by: Yuntao Wang <[email protected]>
> ---
> v1 -> v2: skip core relos if hdr_len < offsetofend(core_relo_len)
> v2 -> v3: fix comment style
>
> [...]

Here is the summary with links:
- [bpf-next,v3] libbpf: Don't return -EINVAL if hdr_len < offsetofend(core_relo_len)
https://git.kernel.org/bpf/bpf-next/c/a6a86da847eb

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html