BPF type compatibility checks (bpf_core_types_are_compat()) are currently duplicated between kernel and user space. That's a historical artifact more than intentional doing and can lead to subtle bugs where one implementation is adjusted but another is forgotten. That happened with the enum64 work, for example, where the libbpf side was changed (commit 23b2a3a8f63a ("libbpf: Add enum64 relocation support")) to use the btf_kind_core_compat() helper function but the kernel side was not (commit 6089fb325cf7 ("bpf: Add btf enum64 support")). This patch set addresses both the duplication issue and fixes the alluded to kind check. For discussion of the topic, please refer to: https://lore.kernel.org/bpf/CAADnVQKbWR7oarBdewgOBZUPzryhRYvEbkhyPJQHHuxq=0K1gw@xxxxxxxxxxxxxx/T/#mcc99f4a33ad9a322afaf1b9276fb1f0b7add9665 Daniel Müller (2): libbpf: Move core "types_are_compat" logic into relo_core.c bpf: Use bpf_core_types_are_compat functionality from relo_core.c kernel/bpf/btf.c | 86 +-------------------------------------- tools/lib/bpf/libbpf.c | 72 +------------------------------- tools/lib/bpf/relo_core.c | 78 +++++++++++++++++++++++++++++++++++ tools/lib/bpf/relo_core.h | 2 + 4 files changed, 83 insertions(+), 155 deletions(-) -- 2.30.2