Kuan-Wei Chiu
65802da747
scripts/sorttable: fix orc_sort_cmp() to maintain symmetry and transitivity
commit 0210d25116 upstream.
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_TYPE_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_TYPE_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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-01-09 13:33:50 +01:00
..
2024-06-05 15:52:34 +02:00
2024-09-01 20:34:49 +09:00
2024-02-15 06:57:19 +09:00
2024-09-28 21:33:11 +02:00
2024-09-05 10:17:03 -05:00
2024-08-05 14:34:23 -07:00
2024-09-01 20:43:29 -07:00
2024-05-10 04:34:52 +09:00
2024-10-07 02:12:27 +09:00
2024-08-20 14:03:39 -04:00
2024-10-31 21:42:20 +09:00
2025-01-09 13:33:48 +01:00
2025-01-09 13:33:48 +01:00
2024-03-15 14:46:31 +01:00
2024-07-16 01:08:37 +09:00
2024-02-23 12:13:09 +01:00
2023-12-29 22:25:20 +09:00
2024-05-02 10:14:52 -06:00
2024-12-05 14:02:09 +01:00
2023-12-29 12:22:28 -08:00
2024-07-29 15:34:22 -06:00
2024-07-19 12:39:34 -07:00
2024-09-01 20:43:41 -07:00
2023-12-29 12:22:25 -08:00
2024-12-05 14:01:21 +01:00
2024-07-29 03:47:00 +09:00
2024-07-29 03:47:00 +09:00
2024-09-20 09:21:43 +09:00
2024-08-07 01:16:52 +02:00
2024-09-16 18:04:37 +02:00
2024-01-03 14:02:17 -07:00
2024-08-26 16:10:12 -06:00
2024-09-01 17:59:01 -07:00
2023-12-29 22:25:20 +09:00
2024-06-28 22:28:47 +10:00
2024-05-07 08:55:23 +10:00
2024-07-20 13:34:54 +09:00
2024-09-20 09:21:52 +09:00
2024-07-16 16:07:14 +09:00
2024-10-13 22:22:28 +02:00
2024-12-05 14:01:28 +01:00
2024-07-15 03:13:32 +09:00
2024-02-29 13:38:03 -08:00
2024-09-24 13:02:06 -07:00
2024-09-01 20:43:28 -07:00
2024-07-16 01:08:37 +09:00
2024-08-20 14:03:39 -04:00
2024-07-18 10:01:55 -07:00
2024-06-21 14:45:07 -07:00
2024-12-14 20:03:34 +01:00
2024-05-10 04:34:52 +09:00
2024-10-10 22:34:41 +02:00
2024-04-02 17:41:22 +02:00
2024-01-28 01:13:37 +09:00
2024-06-26 00:18:57 +09:00
2024-09-30 20:42:52 +09:00
2024-05-19 14:36:16 -07:00
2024-09-08 12:15:46 +09:00
2024-09-16 18:04:37 +02:00
2024-09-25 10:25:40 -07:00
2024-09-20 09:21:53 +09:00
2024-09-28 09:06:15 -07:00
2024-05-18 12:39:20 -07:00
2024-10-31 21:40:46 +09:00
2024-02-20 20:44:49 -08:00
2024-05-21 12:09:36 -07:00
2024-09-20 09:21:43 +09:00
2024-09-20 09:21:43 +09:00
2024-05-05 20:17:25 +02:00
2025-01-09 13:33:47 +01:00
2024-09-07 17:24:08 +09:00
2024-05-19 09:21:03 -07:00
2024-02-22 15:38:54 -08:00
2024-08-15 09:26:02 -07:00
2024-07-10 10:28:52 +02:00
2024-07-10 10:28:52 +02:00
2024-07-10 10:28:52 +02:00
2024-10-28 00:27:16 +01:00
2024-09-05 22:44:18 +02:00
2024-12-14 20:04:10 +01:00
2024-09-20 19:52:48 +03:00
2025-01-09 13:33:50 +01:00
2024-05-04 19:00:54 +02:00
2024-06-28 19:36:28 -07:00
2024-09-05 14:32:36 -06:00
2024-09-20 19:49:52 +03:00
2024-09-10 13:56:37 +09:00
2024-08-06 08:57:02 +02:00
2024-06-28 15:23:38 +02:00
2024-01-04 17:01:15 +01:00
2024-04-23 00:09:41 +09:00
2024-09-20 09:21:52 +09:00
2024-09-01 20:43:27 -07:00