linux-stable/tools
Ian Rogers d2341dc41a libperf evlist: Avoid out-of-bounds access
[ Upstream commit 1947b92464 ]

Parallel testing appears to show a race between allocating and setting
evsel ids. As there is a bounds check on the xyarray it yields a segv
like:

```
AddressSanitizer:DEADLYSIGNAL

=================================================================

==484408==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000010

==484408==The signal is caused by a WRITE memory access.

==484408==Hint: address points to the zero page.

    #0 0x55cef5d4eff4 in perf_evlist__id_hash tools/lib/perf/evlist.c:256
    #1 0x55cef5d4f132 in perf_evlist__id_add tools/lib/perf/evlist.c:274
    #2 0x55cef5d4f545 in perf_evlist__id_add_fd tools/lib/perf/evlist.c:315
    #3 0x55cef5a1923f in store_evsel_ids util/evsel.c:3130
    #4 0x55cef5a19400 in evsel__store_ids util/evsel.c:3147
    #5 0x55cef5888204 in __run_perf_stat tools/perf/builtin-stat.c:832
    #6 0x55cef5888c06 in run_perf_stat tools/perf/builtin-stat.c:960
    #7 0x55cef58932db in cmd_stat tools/perf/builtin-stat.c:2878
...
```

Avoid this crash by early exiting the perf_evlist__id_add_fd and
perf_evlist__id_add is the access is out-of-bounds.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240229070757.796244-1-irogers@google.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-13 12:59:48 +02:00
..
accounting
arch parisc: Drop the HP-UX ENOSYM and EREMOTERELEASE error codes 2023-12-08 08:46:12 +01:00
bootconfig
bpf bpftool: Silence build warning about calloc() 2024-03-26 18:21:49 -04:00
build
cgroup
debugging
edid
firewire
firmware
gpio tools: gpio: fix debounce_period_us output of lsgpio 2023-06-21 15:45:35 +02:00
hv vmbus_testing: fix wrong python syntax for integer value comparison 2023-09-19 12:20:05 +02:00
iio tools: iio: iio_generic_buffer ensure alignment 2023-11-20 11:06:53 +01:00
include objtool: Add asm version of STACK_FRAME_NON_STANDARD 2024-04-13 12:59:39 +02:00
io_uring
kvm/kvm_stat
laptop
leds
lib libperf evlist: Avoid out-of-bounds access 2024-04-13 12:59:48 +02:00
memory-model
objtool objtool/x86: add missing embedded_insn check 2023-11-08 17:30:47 +01:00
pci
pcmcia
perf perf stat: Avoid metric-only segv 2024-03-26 18:21:57 -04:00
power tools/power x86_energy_perf_policy: Fix file leak in get_pkg_num() 2024-04-13 12:59:42 +02:00
scripts
spi
testing selftests: reuseaddr_conflict: add missing new line at the end of the output 2024-04-13 12:59:27 +02:00
thermal/tmon
time
usb
virtio
vm
wmi
Makefile