2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00
linux/tools/lib
Adin Scannell fa6f092cc0 libbpf: Fix possible use-after-free for externs
The `name` field in `obj->externs` points into the BTF data at initial
open time. However, some functions may invalidate this after opening and
before loading (e.g. `bpf_map__set_value_size`), which results in
pointers into freed memory and undefined behavior.

The simplest solution is to simply `strdup` these strings, similar to
the `essent_name`, and free them at the same time.

In order to test this path, the `global_map_resize` BPF selftest is
modified slightly to ensure the presence of an extern, which causes this
test to fail prior to the fix. Given there isn't an obvious API or error
to test against, I opted to add this to the existing test as an aspect
of the resizing feature rather than duplicate the test.

Fixes: 9d0a23313b ("libbpf: Add capability for resizing datasec maps")
Signed-off-by: Adin Scannell <amscanne@meta.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250625050215.2777374-1-amscanne@meta.com
2025-06-25 12:28:58 -07:00
..
api libapi: Add missing header with NAME_MAX define to io_dir.h 2025-03-13 00:29:36 -07:00
bpf libbpf: Fix possible use-after-free for externs 2025-06-25 12:28:58 -07:00
perf libperf threadmap: Add perf_thread_map__idx() 2025-05-21 15:07:13 -03:00
subcmd perf tools changes for v6.13 2024-11-26 14:54:00 -08:00
symbol tools: Drop nonsensical -O6 2024-09-11 13:08:36 -03:00
thermal tools: Remove redundant quiet setup 2025-02-18 16:27:43 -03:00
argv_split.c
bitmap.c lib/interval_tree: add test case for interval_tree_iter_xxx() helpers 2025-03-17 12:17:00 -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