linux-stable/tools
Andrii Nakryiko 0cfbadb153 libbpf: Fix realloc API handling in zero-sized edge cases
[ Upstream commit 8a0260dbf6 ]

realloc() and reallocarray() can either return NULL or a special
non-NULL pointer, if their size argument is zero. This requires a bit
more care to handle NULL-as-valid-result situation differently from
NULL-as-error case. This has caused real issues before ([0]), and just
recently bit again in production when performing bpf_program__attach_usdt().

This patch fixes 4 places that do or potentially could suffer from this
mishandling of NULL, including the reported USDT-related one.

There are many other places where realloc()/reallocarray() is used and
NULL is always treated as an error value, but all those have guarantees
that their size is always non-zero, so those spot don't need any extra
handling.

  [0] d08ab82f59 ("libbpf: Fix double-free when linker processes empty sections")

Fixes: 999783c8bb ("libbpf: Wire up spec management and other arch-independent USDT logic")
Fixes: b63b3c490e ("libbpf: Add bpf_program__set_insns function")
Fixes: 697f104db8 ("libbpf: Support custom SEC() handlers")
Fixes: b126882672 ("libbpf: Change the order of data and text relocations.")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20230711024150.1566433-1-andrii@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-09-13 09:42:30 +02:00
..
accounting
arch x86/bugs: Increase the x86 bugs vector size to two u32s 2023-08-08 20:03:50 +02:00
bootconfig bootconfig: Fix testcase to increase max node 2023-03-30 12:49:07 +02:00
bpf bpftool: Use a local bpf_perf_event_value to fix accessing its fields 2023-09-13 09:42:30 +02:00
build perf bpf: Fix build with libbpf 0.7.0 by checking if bpf_program__set_insns() is available 2022-10-25 17:40:48 -03:00
certs
cgroup
counter
debugging
edid
firewire
firmware
gpio tools: gpio: fix debounce_period_us output of lsgpio 2023-06-21 16:00:52 +02:00
hv vmbus_testing: fix wrong python syntax for integer value comparison 2023-09-13 09:42:23 +02:00
iio tools/iio/iio_utils:fix memory leak 2023-03-11 13:55:35 +01:00
include tools headers UAPI: Sync the linux/in.h with the kernel sources 2023-06-05 09:26:22 +02:00
io_uring
kvm/kvm_stat tools/kvm_stat: update exit reasons for vmx/svm/aarch64/userspace 2022-11-09 12:26:52 -05:00
laptop
leds
lib libbpf: Fix realloc API handling in zero-sized edge cases 2023-09-13 09:42:30 +02:00
memory-model
objtool objtool/x86: Fix SRSO mess 2023-08-27 21:01:31 +02:00
pci
pcmcia
perf perf test uprobe_from_different_cu: Skip if there is no gcc 2023-08-11 12:08:13 +02:00
power cpupower: Make TSC read per CPU for Mperf monitor 2023-05-24 17:32:43 +01:00
rcu
scripts
spi
testing selftests/bpf: Fix bpf_nf failure upon test rerun 2023-09-13 09:42:30 +02:00
thermal
time
tracing tools/tracing/rtla: osnoise_hist: use total duration for average calculation 2023-03-10 09:33:26 +01:00
usb
verification rv/dot2c: Make automaton definition static 2022-10-20 16:02:45 -04:00
virtio tools/virtio: fix the vringh test for virtio ring changes 2023-02-22 12:59:42 +01:00
vm tools/mm/page_owner_sort.c: fix TGID output when cull=tg is used 2023-04-26 14:28:39 +02:00
wmi
Makefile