mirror of https://github.com/torvalds/linux.git
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:
|
||
|---|---|---|
| .. | ||
| Build | ||
| bench.h | ||
| breakpoint.c | ||
| epoll-ctl.c | ||
| epoll-wait.c | ||
| evlist-open-close.c | ||
| find-bit-bench.c | ||
| futex-hash.c | ||
| futex-lock-pi.c | ||
| futex-requeue.c | ||
| futex-wake-parallel.c | ||
| futex-wake.c | ||
| futex.h | ||
| inject-buildid.c | ||
| kallsyms-parse.c | ||
| mem-functions.c | ||
| mem-memcpy-arch.h | ||
| mem-memcpy-x86-64-asm-def.h | ||
| mem-memcpy-x86-64-asm.S | ||
| mem-memset-arch.h | ||
| mem-memset-x86-64-asm-def.h | ||
| mem-memset-x86-64-asm.S | ||
| numa.c | ||
| pmu-scan.c | ||
| sched-messaging.c | ||
| sched-pipe.c | ||
| sched-seccomp-notify.c | ||
| synthesize.c | ||
| syscall.c | ||
| uprobe.c | ||