mbox series

[bpf-next,0/2] Deduplicate type compat check

Message ID 20220622173506.860578-1-deso@posteo.net (mailing list archive)
Headers show
Series Deduplicate type compat check | expand

Message

Daniel Müller June 22, 2022, 5:35 p.m. UTC
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@mail.gmail.com/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(-)