linux-yocto/tools
Adin Scannell ad9c4941d3 libbpf: Fix possible use-after-free for externs
[ Upstream commit fa6f092cc0 ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-07-06 11:00:12 +02:00
..
accounting
arch tools/x86/kcpuid: Fix error handling 2025-06-19 15:28:01 +02:00
bootconfig tools/bootconfig: Fix the wrong format specifier 2025-02-08 09:52:28 +01:00
bpf tools/resolve_btfids: Fix build when cross compiling kernel with clang. 2025-06-19 15:28:44 +02:00
build tools/build: Don't pass test log files to linker 2025-06-04 14:41:56 +02:00
certs
cgroup
counter
crypto/ccp
debugging
edid
firewire
firmware
gpio
hv tools: hv: change permissions of NetworkManager configuration file 2024-12-27 13:58:46 +01:00
iio tools/iio: Add memory allocation failure check for trigger_name 2024-10-17 15:24:20 +02:00
include bpf: Fix L4 csum update on IPv6 in CHECKSUM_COMPLETE 2025-06-27 11:09:00 +01:00
kvm/kvm_stat
laptop
leds
lib libbpf: Fix possible use-after-free for externs 2025-07-06 11:00:12 +02:00
memory-model
mm tools/mm: fix compile error 2024-11-22 15:38:33 +01:00
net/ynl tools: ynl-gen: validate 0 len strings from kernel 2025-06-04 14:42:16 +02:00
objtool objtool: Fix error handling inconsistencies in check() 2025-06-04 14:41:58 +02:00
pci
pcmcia
perf perf evsel: Missed close() when probing hybrid core PMUs 2025-06-27 11:09:04 +01:00
power pm: cpupower: bench: Prevent NULL dereference on malloc failure 2025-04-25 10:45:10 +02:00
rcu
scripts tools: Override makefile ARCH variable if defined, but empty 2024-12-14 19:59:49 +01:00
spi
testing libbpf: Fix possible use-after-free for externs 2025-07-06 11:00:12 +02:00
thermal
time
tracing rtla/timerlat_top: Set OSNOISE_WORKLOAD for kernel threads 2025-03-07 16:45:49 +01:00
usb usbip: tools: Fix detach_port() invalid port error path 2024-11-08 16:28:22 +01:00
verification verification/dot2: Improve dot parser robustness 2024-12-14 20:00:13 +01:00
virtio
wmi
workqueue
Makefile