Skip to content

Commit e93f399

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 <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 88d01a5 commit e93f399

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)