From: Yuntao Wang Date: Mon, 4 Apr 2022 00:53:20 +0000 (+0800) Subject: libbpf: Don't return -EINVAL if hdr_len < offsetofend(core_relo_len) X-Git-Tag: for-5.19/block-exec-2022-06-02~49^2~363^2~30 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=e93f39998d8f8ed456dfbb4ca68f9a159906cc6f;p=linux-2.6-block.git 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 Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20220404005320.1723055-1-ytcoode@gmail.com --- 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)