Skip to content

libbpf: Fix array comparison in BTF dedup

Mingpei CAO bpf 2 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 0 repliesApplied 2/2
  2. v12 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- Move the tests into prog_tests/btf.c using Alan Maguire's two cases.
- Add a separate negative case with the same index type to isolate element-type comparison.
- Keep patch 1 unchanged.

Patches in v2 All 2 applied

#Subject and filesSizeRepliesApplied
1/2libbpf: Fix array comparison in BTF deduptools/lib/bpf/btf.c+1 -10 repliesApplied
2/2selftests/bpf: Test array element comparison in BTF deduptools/testing/selftests/bpf/prog_tests/btf.c+126 -00 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH bpf v2 0/2] libbpf: Fix array comparison in BTF dedup

The recursive array comparison in BTF dedup reads both descriptors from the first type. This can merge distinct structures and corrupt CO-RE relocation metadata. Fix the comparison and add three regression cases to the existing BTF dedup tests.

Changes in v2:
- Move the tests into prog_tests/btf.c using Alan Maguire's two cases.
- Add a separate negative case with the same index type to isolate element-type comparison.
- Keep patch 1 unchanged.

v1: https://lore.kernel.org/bpf/[email protected]/
Report: https://lore.kernel.org/bpf/CABzjXVz3iBuump-pXFkefZ5v+2uu4fG61zqRyWD4xmz3PuBycw@mail.gmail.com/

Validation with a focused runner using the existing selftest sources and assertions:
- 52 existing BTF cases passed before and after the fix.
- Both negative cases failed before the fix and passed afterwards.
- The positive case passed before and after the fix.

Mingpei CAO (2):
libbpf: Fix array comparison in BTF dedup selftests/bpf: Test array element comparison in BTF dedup

 tools/lib/bpf/btf.c                          |   2 +-
 tools/testing/selftests/bpf/prog_tests/btf.c | 126 +++++++++++++++++++
 2 files changed, 127 insertions(+), 1 deletion(-)

base-commit: df2908090cda368b01ff43709f51890076c56157

Signature · 1 line
2.43.0