]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
libbpf: Make btf__resolve_size logic always check size error condition
authorAndrii Nakryiko <andriin@fb.com>
Thu, 7 Nov 2019 02:08:54 +0000 (18:08 -0800)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 6 Mar 2020 07:25:26 +0000 (02:25 -0500)
BugLink: https://bugs.launchpad.net/bugs/1864060
commit 994021a7e08477f7e51285920aac99fc967fae8a upstream.

Perform size check always in btf__resolve_size. Makes the logic a bit more
robust against corrupted BTF and silences LGTM/Coverity complaining about
always true (size < 0) check.

Fixes: 69eaab04c675 ("btf: extract BTF type size calculation")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20191107020855.3834758-5-andriin@fb.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
tools/lib/bpf/btf.c

index d821107f55f90ff5c823d4ff1c19432268132a84..f9ee1bb271e45c9d73e29a99b54f602e849fed4a 100644 (file)
@@ -317,10 +317,9 @@ __s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
                t = btf__type_by_id(btf, type_id);
        }
 
+done:
        if (size < 0)
                return -EINVAL;
-
-done:
        if (nelems && size > UINT32_MAX / nelems)
                return -E2BIG;