
Kuan-Wei ChiuandGreg Kroah-Hartman
939d239fe8
scripts/sorttable: fix orc_sort_cmp() to maintain symmetry and transitivity
The orc_sort_cmp() function, used with qsort(), previously violated the
symmetry and transitivity rules required by the C standard. Specifically,
when both entries are ORC_REG_UNDEFINED, it could result in both a < b
and b < a, which breaks the required symmetry and transitivity. This can
lead to undefined behavior and incorrect sorting results, potentially
causing memory corruption in glibc implementations [1].
Symmetry: If x < y, then y > x.
Transitivity: If x < y and y < z, then x < z.
Fix the comparison logic to return 0 when both entries are
ORC_REG_UNDEFINED, ensuring compliance with qsort() requirements.
Link: https://www.qualys.com/2024/01/30/qsort.txt [1]
Link: https://lkml.kernel.org/r/20241226140332.2670689-1-visitorckw@gmail.com
Fixes: 57fa189942 ("scripts/sorttable: Implement build-time ORC unwind table sorting")
Fixes: fb799447ae ("x86,objtool: Split UNWIND_HINT_EMPTY in two")
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Cc: Ching-Chun (Jim) Huang <jserv@ccns.ncku.edu.tw>
Cc: <chuang@cs.nycu.edu.tw>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Shile Zhang <shile.zhang@linux.alibaba.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 0210d25116)
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-01-17 13:34:38 +01:00
..
2023-02-01 08:34:49 +01:00
2024-03-26 18:20:25 -04:00
2022-08-07 21:30:36 +02:00
2023-12-13 18:39:05 +01:00
2022-08-21 02:47:48 +09:00
2024-07-25 09:49:07 +02:00
2024-06-16 13:41:32 +02:00
2024-10-17 15:22:03 +02:00
2025-01-09 13:30:05 +01:00
2023-09-19 12:27:58 +02:00
2022-09-20 14:12:25 -04:00
2023-02-01 08:34:37 +01:00
2022-09-28 09:02:06 +02:00
2023-06-21 16:01:03 +02:00
2023-04-26 14:28:44 +02:00
2022-07-17 17:31:40 -07:00
2024-04-10 16:28:21 +02:00
2022-09-28 09:02:20 +02:00
2022-09-29 04:40:15 +09:00
2023-03-17 08:50:31 +01:00
2024-02-23 09:12:51 +01:00
2023-12-13 18:39:19 +01:00
2024-01-20 11:50:11 +01:00
2022-09-11 21:55:05 -07:00
2023-03-17 08:50:31 +01:00
2022-08-29 13:58:47 +09:00
2022-11-16 10:42:10 +01:00
2024-08-03 08:49:39 +02:00
2024-08-03 08:49:39 +02:00
2022-09-28 09:02:06 +02:00
2022-09-28 09:02:45 +02:00
2024-01-31 16:17:01 -08:00
2023-06-28 11:12:22 +02:00
2023-02-25 11:25:42 +01:00
2022-07-27 21:18:00 +09:00
2023-10-25 12:03:16 +02:00
2022-09-29 02:00:29 +09:00
2023-06-21 16:01:03 +02:00
2024-07-18 13:18:44 +02:00
2024-07-11 12:47:18 +02:00
2022-09-28 09:02:20 +02:00
2024-05-17 11:56:10 +02:00
2024-01-25 15:27:18 -08:00
2022-09-28 09:02:20 +02:00
2024-07-05 09:31:57 +02:00
2024-04-03 15:19:34 +02:00
2022-08-16 12:25:53 -07:00
2024-05-17 11:56:10 +02:00
2022-10-03 14:03:19 -07:00
2024-08-03 08:49:48 +02:00
2024-05-17 11:56:17 +02:00
2023-02-09 11:28:11 +01:00
2024-02-23 09:12:38 +01:00
2022-11-24 09:27:57 +09:00
2022-10-03 03:52:58 +09:00
2022-10-03 03:52:58 +09:00
2022-11-09 18:41:16 +01:00
2022-09-29 04:40:15 +09:00
2022-10-03 03:51:58 +09:00
2022-09-26 10:13:13 -07:00
2024-01-20 11:50:10 +01:00
2023-05-24 17:32:41 +01:00
2022-08-12 18:39:43 -07:00
2022-09-28 09:02:06 +02:00
2024-08-29 17:30:32 +02:00
2023-12-20 17:00:19 +01:00
2025-01-17 13:34:38 +01:00
2022-07-07 12:47:34 -06:00
2023-07-05 18:27:38 +01:00