diff mbox series

[bpf-next,v2] libbpf: Don't return -EINVAL if hdr_len < offsetofend(core_relo_len)

Message ID 20220316145213.868746-1-ytcoode@gmail.com (mailing list archive)
State New, archived
Delegated to: BPF
Headers show
Series [bpf-next,v2] libbpf: Don't return -EINVAL if hdr_len < offsetofend(core_relo_len) | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: line length of 86 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next fail VM_Test
bpf/vmtest-bpf-next-PR fail PR summary

Commit Message

Yuntao Wang March 16, 2022, 2:52 p.m. UTC
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).

Fixes: e9fc3ce99b34 ("libbpf: Streamline error reporting for high-level APIs")
Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
---
v1 -> v2: skip core relos if hdr_len < offsetofend(core_relo_len)

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

Comments

Andrii Nakryiko April 3, 2022, 11:10 p.m. UTC | #1
On Wed, Mar 16, 2022 at 7:52 AM Yuntao Wang <ytcoode@gmail.com> 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).
>
> Fixes: e9fc3ce99b34 ("libbpf: Streamline error reporting for high-level APIs")
> Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
> ---
> v1 -> v2: skip core relos if hdr_len < offsetofend(core_relo_len)
>

Seems like this never made it to Patchworks. Can you please trim down
the CC list and resubmit?

>  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..9b7196b21498 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

don't use C++-style comments, only /* */

>
>         err = btf_ext_setup_core_relos(btf_ext);
>         if (err)
> --
> 2.35.1
>
diff mbox series

Patch

diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 1383e26c5d1f..9b7196b21498 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)