]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
libbpf: Add identical pointer detection to btf_dedup_is_equiv()
authorAlan Maguire <alan.maguire@oracle.com>
Tue, 29 Apr 2025 16:10:42 +0000 (17:10 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:07:34 +0000 (11:07 +0100)
commit7d8c7994d806f720f2e54fc867aa76b869ea13b1
tree44c3a8135a6630e72dd03a480f968c4566e0f208
parent5fe149fdff54a4a8cca8d9f0989ce97930e2deb5
libbpf: Add identical pointer detection to btf_dedup_is_equiv()

[ Upstream commit 8e64c387c942229c551d0f23de4d9993d3a2acb6 ]

Recently as a side-effect of

commit ac053946f5c4 ("compiler.h: introduce TYPEOF_UNQUAL() macro")

issues were observed in deduplication between modules and kernel BTF
such that a large number of kernel types were not deduplicated so
were found in module BTF (task_struct, bpf_prog etc).  The root cause
appeared to be a failure to dedup struct types, specifically those
with members that were pointers with __percpu annotations.

The issue in dedup is at the point that we are deduplicating structures,
we have not yet deduplicated reference types like pointers.  If multiple
copies of a pointer point at the same (deduplicated) integer as in this
case, we do not see them as identical.  Special handling already exists
to deal with structures and arrays, so add pointer handling here too.

Reported-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250429161042.2069678-1-alan.maguire@oracle.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/lib/bpf/btf.c