diff options
| author | Kuan-Wei Chiu <[email protected]> | 2025-01-16 11:08:42 +0000 |
|---|---|---|
| committer | Namhyung Kim <[email protected]> | 2025-01-18 18:14:36 +0000 |
| commit | 62892e77b8a64b9dc0e1da75980aa145347b6820 (patch) | |
| tree | a21d0dcdb4b7a136b2c96ced1be4f751f501c658 /drivers/platform/x86/intel/pmt/class.c | |
| parent | perf annotate: Prefer passing evsel to evsel->core.idx (diff) | |
| download | kernel-62892e77b8a64b9dc0e1da75980aa145347b6820.tar.gz kernel-62892e77b8a64b9dc0e1da75980aa145347b6820.zip | |
perf bench: Fix undefined behavior in cmpworker()
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: 121dd9ea0116 ("perf bench: Add epoll parallel epoll_wait benchmark")
Cc: [email protected]
Signed-off-by: Kuan-Wei Chiu <[email protected]>
Reviewed-by: James Clark <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Diffstat (limited to 'drivers/platform/x86/intel/pmt/class.c')
0 files changed, 0 insertions, 0 deletions
