linux/tools
Kuan-Wei Chiu a0d751d2d8 perf bench: Fix undefined behavior in cmpworker()
commit 62892e77b8 upstream.

The comparison function cmpworker() violates the C standard's
requirements for qsort() comparison functions, which mandate symmetry
and transitivity:

Symmetry: If x < y, then y > x.
Transitivity: If x < y and y < z, then x < z.

In its current implementation, cmpworker() incorrectly returns 0 when
w1->tid < w2->tid, which breaks both symmetry and transitivity. This
violation causes undefined behavior, potentially leading to issues such
as memory corruption in glibc [1].

Fix the issue by returning -1 when w1->tid < w2->tid, ensuring
compliance with the C standard and preventing undefined behavior.

Link: https://www.qualys.com/2024/01/30/qsort.txt [1]
Fixes: 121dd9ea01 ("perf bench: Add epoll parallel epoll_wait benchmark")
Cc: stable@vger.kernel.org
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Reviewed-by: James Clark <james.clark@linaro.org>
Link: https://lore.kernel.org/r/20250116110842.4087530-1-visitorckw@gmail.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2025-03-13 12:50:26 +01:00
..
accounting SPDX patches for 5.7-rc1. 2020-04-03 13:12:26 -07:00
arch tools/x86/kcpuid: Protect against faulty "max subleaf" values 2024-10-17 15:11:28 +02:00
bootconfig tools/bootconfig: Fix the wrong format specifier 2025-03-13 12:50:10 +01:00
bpf bpftool: fix potential NULL pointer dereferencing in prog_dump() 2024-12-14 19:51:29 +01:00
build perf cs-etm: Bump minimum OpenCSD version to ensure a bugfix is present 2024-02-23 08:54:50 +01:00
cgroup tools/cgroup/slabinfo.py: updated to work on current kernel 2021-04-23 14:42:40 -07:00
debugging tools: Fix "the the" in a message in kernel-chktaint 2021-06-13 17:01:17 -06:00
edid tools/edid: Move EDID data sets from Documentation/ 2020-02-19 04:10:32 -07:00
firewire treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
firmware Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
gpio tools: gpio: fix debounce_period_us output of lsgpio 2023-06-21 15:59:12 +02:00
hv vmbus_testing: fix wrong python syntax for integer value comparison 2023-09-19 12:22:28 +02:00
iio tools/iio: Add memory allocation failure check for trigger_name 2024-10-17 15:11:52 +02:00
include tools: move alignment-related macros to new <linux/align.h> 2024-09-04 13:23:37 +02:00
io_uring tools/io_uring/io_uring-cp: sync with liburing example 2021-08-13 08:58:11 -06:00
kvm/kvm_stat tools/kvm_stat: fix display of error when multiple processes are found 2022-08-11 13:07:51 +02:00
laptop change email address for Pali Rohár 2020-04-10 15:36:22 -07:00
leds .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
lib libbpf: Fix segfault due to libelf functions not setting errno 2025-03-13 12:50:00 +01:00
memory-model tools/memory-model: Fix bug in lock.cat 2024-08-19 05:45:15 +02:00
objtool objtool/x86: allow syscall instruction 2024-12-19 18:07:22 +01:00
pci tools: PCI: Zero-initialize param 2021-08-05 11:01:30 +01:00
pcmcia .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
perf perf bench: Fix undefined behavior in cmpworker() 2025-03-13 12:50:26 +01:00
power cpupower: fix TSC MHz calculation 2025-03-13 12:49:56 +01:00
rcu tools/rcu: Add drgn script to dump number of RCU callbacks 2021-05-10 15:39:19 -07:00
scripts tools: Override makefile ARCH variable if defined, but empty 2024-12-14 19:51:30 +01:00
spi spi: tools: make a symbolic link to the header file spi.h 2021-04-22 16:30:39 +01:00
testing udp: gso: do not drop small packets when PMTU reduces 2025-03-13 12:50:22 +01:00
thermal/tmon tools/thermal: Fix possible path truncations 2022-08-17 14:24:15 +02:00
time treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
tracing tools/latency-collector: Fix -Wformat-security compile warns 2024-06-16 13:39:12 +02:00
usb usbip: tools: Fix detach_port() invalid port error path 2024-11-08 16:25:54 +01:00
virtio tools/virtio: fix build 2024-03-01 13:21:52 +01:00
vm tools/vm/slabinfo-gnuplot: use "grep -E" instead of "egrep" 2022-12-08 11:28:42 +01:00
wmi treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
Makefile tracing/tools: Add the latency-collector to tools directory 2021-02-12 11:52:59 -05:00