Skip to content

Commit a6a86da

Browse files
ytcoodeanakryiko
authored andcommitted
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 <ytcoode@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20220404005320.1723055-1-ytcoode@gmail.com
1 parent 6d4527c commit a6a86da

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

tools/lib/bpf/btf.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,10 +2826,8 @@ struct btf_ext *btf_ext__new(const __u8 *data, __u32 size)
28262826
if (err)
28272827
goto done;
28282828

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

28342832
err = btf_ext_setup_core_relos(btf_ext);
28352833
if (err)

0 commit comments

Comments
 (0)