]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: fix btf_dedup equivalence check handling of different kinds
authorAndrii Nakryiko <andriin@fb.com>
Wed, 27 Mar 2019 05:00:06 +0000 (22:00 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 27 Mar 2019 15:01:24 +0000 (08:01 -0700)
commit1c80b56cd269fcc1052848299c6a141a5edccbf1
treebd87aa5336f9fc120dafd44f4e9197359cb704bb
parente30e9fee38d5e9505b373bd584a89f421bbd27fb
libbpf: fix btf_dedup equivalence check handling of different kinds

btf_dedup_is_equiv() used to compare btf_type->info fields, before doing
kind-specific equivalence check. This comparsion implicitly verified
that candidate and canonical types are of the same kind. With enum fwd
resolution logic this check couldn't be done generically anymore, as for
enums info contains vlen, which differs between enum fwd and
fully-defined enum, so this check was subsumed by kind-specific
equivalence checks.

This change caused btf_dedup_is_equiv() to let through VOID vs other
types check to reach switch, which was never meant to be handing VOID
kind, as VOID kind is always pre-resolved to itself and is only
equivalent to itself, which is checked early in btf_dedup_is_equiv().

This change adds back BTF kind equality check in place of more generic
btf_type->info check, still defering further kind-specific checks to
a per-kind switch.

Fixes: 0fd86cc0066f ("btf: resolve enum fwds in btf_dedup")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/btf.c