linux/tools/lib
Kumar Kartikeya Dwivedi b4e875d397 libbpf: Reject truncated ldimm64 CO-RE relocations
CO-RE relocation of an ldimm64 instruction operates on two instruction
slots. A malformed BPF ELF can end a function after the first slot and
attach a CO-RE relocation to it. libbpf allocates the instruction array
according to the function symbol size, so the shared relocation code would
then access beyond the allocation.

Reject a terminal ldimm64 in libbpf's relocation loop, where the program
length is available, before resolving or applying the relocation. Both
resolved and unresolved relocations validate the absent second slot, and
unresolved relocation poisoning would additionally write past the array.

The in-kernel caller is protected by the verifier's early instruction-stream
check before it applies CO-RE relocations.

Fixes: eacaaed784 ("libbpf: Implement enum value-based CO-RE relocations")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/20260914140852.03DA21F0089B@smtp.kernel.org
Link: https://patch.msgid.link/20260917233222.2542500-11-memxor@gmail.com
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
2026-09-17 18:01:43 -07:00
..
api tools/build: selftests: Remove some duplicate toolchain definitions 2026-07-25 22:25:00 -07:00
bpf libbpf: Reject truncated ldimm64 CO-RE relocations 2026-09-17 18:01:43 -07:00
perf libperf: Document code simplification case for widening struct perf_cpu 2026-06-10 15:23:54 -03:00
python docs: python: abi_regex: convert adjacent index placeholders 2026-08-11 10:36:28 -06:00
subcmd tools/build: selftests: Remove some duplicate toolchain definitions 2026-07-25 22:25:00 -07:00
symbol tools/build: selftests: Remove some duplicate toolchain definitions 2026-07-25 22:25:00 -07:00
thermal tools/lib/thermal: Fix misplaced extern "C" closing brace 2026-08-07 17:18:51 +02:00
argv_split.c
bitmap.c mm/vma: add vma_flags_empty(), vma_flags_and(), vma_flags_diff_pair() 2026-04-05 13:53:38 -07:00
cmdline.c memblock test: fix implicit declaration of function 'memparse' 2024-08-06 08:21:25 +03:00
ctype.c
find_bit.c tools: sync find_bit() implementation 2022-09-21 12:21:44 -07:00
hweight.c
list_sort.c tools/lib/list_sort: remove unnecessary header includes 2024-11-05 17:12:33 -08:00
rbtree.c tools lib rbtree: pick some improvements from the kernel rbtree code 2024-05-08 08:41:27 -07:00
slab.c lib/rbtree: enable userland test suite for rbtree related data structure 2025-03-17 12:17:00 -07:00
str_error_r.c
string.c perf annotate: Add disasm_line__parse() to parse raw instruction for powerpc 2024-07-31 16:12:59 -03:00
vsprintf.c
zalloc.c