Qiang Zhang
e46d3be714
bootconfig: use memblock_free_late to free xbc memory to buddy
...
commit 89f9a1e876b5a7ad884918c03a46831af202c8a0 upstream.
On the time to free xbc memory in xbc_exit(), memblock may has handed
over memory to buddy allocator. So it doesn't make sense to free memory
back to memblock. memblock_free() called by xbc_exit() even causes UAF bugs
on architectures with CONFIG_ARCH_KEEP_MEMBLOCK disabled like x86.
Following KASAN logs shows this case.
This patch fixes the xbc memory free problem by calling memblock_free()
in early xbc init error rewind path and calling memblock_free_late() in
xbc exit path to free memory to buddy allocator.
[ 9.410890] ==================================================================
[ 9.418962] BUG: KASAN: use-after-free in memblock_isolate_range+0x12d/0x260
[ 9.426850] Read of size 8 at addr ffff88845dd30000 by task swapper/0/1
[ 9.435901] CPU: 9 PID: 1 Comm: swapper/0 Tainted: G U 6.9.0-rc3-00208-g586b5dfb51b9 #5
[ 9.446403] Hardware name: Intel Corporation RPLP LP5 (CPU:RaptorLake)/RPLP LP5 (ID:13), BIOS IRPPN02.01.01.00.00.19.015.D-00000000 Dec 28 2023
[ 9.460789] Call Trace:
[ 9.463518] <TASK>
[ 9.465859] dump_stack_lvl+0x53/0x70
[ 9.469949] print_report+0xce/0x610
[ 9.473944] ? __virt_addr_valid+0xf5/0x1b0
[ 9.478619] ? memblock_isolate_range+0x12d/0x260
[ 9.483877] kasan_report+0xc6/0x100
[ 9.487870] ? memblock_isolate_range+0x12d/0x260
[ 9.493125] memblock_isolate_range+0x12d/0x260
[ 9.498187] memblock_phys_free+0xb4/0x160
[ 9.502762] ? __pfx_memblock_phys_free+0x10/0x10
[ 9.508021] ? mutex_unlock+0x7e/0xd0
[ 9.512111] ? __pfx_mutex_unlock+0x10/0x10
[ 9.516786] ? kernel_init_freeable+0x2d4/0x430
[ 9.521850] ? __pfx_kernel_init+0x10/0x10
[ 9.526426] xbc_exit+0x17/0x70
[ 9.529935] kernel_init+0x38/0x1e0
[ 9.533829] ? _raw_spin_unlock_irq+0xd/0x30
[ 9.538601] ret_from_fork+0x2c/0x50
[ 9.542596] ? __pfx_kernel_init+0x10/0x10
[ 9.547170] ret_from_fork_asm+0x1a/0x30
[ 9.551552] </TASK>
[ 9.555649] The buggy address belongs to the physical page:
[ 9.561875] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x1 pfn:0x45dd30
[ 9.570821] flags: 0x200000000000000(node=0|zone=2)
[ 9.576271] page_type: 0xffffffff()
[ 9.580167] raw: 0200000000000000 ffffea0011774c48 ffffea0012ba1848 0000000000000000
[ 9.588823] raw: 0000000000000001 0000000000000000 00000000ffffffff 0000000000000000
[ 9.597476] page dumped because: kasan: bad access detected
[ 9.605362] Memory state around the buggy address:
[ 9.610714] ffff88845dd2ff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[ 9.618786] ffff88845dd2ff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[ 9.626857] >ffff88845dd30000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 9.634930] ^
[ 9.638534] ffff88845dd30080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 9.646605] ffff88845dd30100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
[ 9.654675] ==================================================================
Link: https://lore.kernel.org/all/20240414114944.1012359-1-qiang4.zhang@linux.intel.com/
Fixes: 40caa127f3c7 ("init: bootconfig: Remove all bootconfig data when the init memory is removed")
Cc: Stable@vger.kernel.org
Signed-off-by: Qiang Zhang <qiang4.zhang@intel.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-04-27 17:11:43 +02:00
..
2020-08-10 01:32:59 +09:00
2024-01-31 16:18:49 -08:00
2023-05-09 11:06:45 +02:00
2022-11-18 13:55:09 -08:00
2024-03-26 18:19:18 -04:00
2022-06-15 10:29:10 +02:00
2022-07-17 17:31:39 -07:00
2022-07-29 18:12:34 -07:00
2023-07-09 22:47:50 +01:00
2023-04-13 13:13:53 -07:00
2023-09-06 22:53:55 +08:00
2022-11-18 02:15:15 +01:00
2022-02-13 16:50:06 -08:00
2023-03-21 21:15:34 +01:00
2021-10-19 23:44:30 +08:00
2023-02-27 17:00:14 -08:00
2023-02-02 22:50:10 -08:00
2023-02-02 22:50:09 -08:00
2023-12-13 18:44:58 +01:00
2022-04-26 17:58:51 -04:00
2023-09-19 13:21:33 -07:00
2020-11-18 14:15:17 -06:00
2022-01-20 08:52:55 +02:00
2022-06-01 18:29:06 -07:00
2021-12-13 10:56:09 +01:00
2021-10-01 16:52:48 -04:00
2022-08-02 17:14:47 -06:00
2023-08-18 10:18:58 -07:00
2020-10-16 13:25:14 -06:00
2023-06-22 13:57:41 -07:00
2022-04-26 17:58:51 -04:00
2024-04-27 17:11:43 +02:00
2023-04-13 13:13:54 -07:00
2023-01-31 15:01:45 +01:00
2023-04-08 13:45:37 -07:00
2022-09-01 16:55:35 +02:00
2023-08-25 10:14:34 +01:00
2020-08-20 15:45:14 -04:00
2023-08-25 13:22:10 -07:00
2024-03-26 18:19:18 -04:00
2022-09-11 21:55:06 -07:00
2021-10-01 16:52:48 -04:00
2023-06-07 21:25:00 -07:00
2023-03-05 14:30:34 -08:00
2023-07-17 15:47:21 -07:00
2021-01-21 14:06:00 -07:00
2021-05-06 19:24:12 -07:00
2022-01-31 11:21:43 +11:00
2022-01-31 11:21:43 +11:00
2022-03-07 12:48:35 -07:00
2022-03-07 12:48:35 -07:00
2022-06-07 10:27:38 +02:00
2021-08-19 09:02:55 +09:00
2021-06-22 13:56:43 +02:00
2024-02-05 20:14:14 +00:00
2023-01-31 20:37:18 +01:00
2021-07-01 11:06:05 -07:00
2023-06-09 17:44:17 -07:00
2021-07-01 11:06:06 -07:00
2021-05-06 19:24:12 -07:00
2021-07-01 11:06:06 -07:00
2023-06-09 17:44:17 -07:00
2023-06-09 17:44:17 -07:00
2020-07-31 11:49:08 +02:00
2023-06-09 17:44:15 -07:00
2023-06-23 17:04:04 -07:00
2023-07-08 09:29:32 -07:00
2023-02-02 22:50:01 -08:00
2023-03-23 17:18:35 -07:00
2023-02-02 22:50:01 -08:00
2020-11-20 14:45:33 +11:00
2022-04-22 21:30:57 +02:00
2023-08-04 15:28:41 +02:00
2020-10-16 11:11:20 -07:00
2022-09-11 21:55:10 -07:00
2023-12-08 08:52:20 +01:00
2023-08-18 10:18:55 -07:00
2020-12-15 22:46:15 -08:00
2021-01-03 20:05:18 -05:00
2020-10-16 11:11:22 -07:00
2023-04-13 07:38:54 -06:00
2022-11-18 02:15:15 +01:00
2023-03-19 10:02:04 -07:00
2022-09-19 14:35:08 +02:00
2023-07-03 12:50:26 -07:00
2022-03-07 12:48:35 -07:00
2023-08-30 17:04:28 -07:00
2023-11-28 17:19:35 +00:00
2022-04-29 14:38:01 -07:00
2023-12-13 18:45:22 +01:00
2023-02-08 14:28:17 -07:00
2022-04-27 10:57:33 -07:00
2024-01-20 11:51:46 +01:00
2022-11-29 16:34:15 -04:00
2022-10-03 14:03:21 -07:00
2023-09-09 15:11:49 -07:00
2022-04-13 21:32:21 +02:00
2022-11-19 00:56:15 +01:00
2021-08-19 09:02:55 +09:00
2023-08-18 10:18:58 -07:00
2024-03-01 13:34:59 +01:00
2023-03-02 21:54:22 -08:00
2023-02-25 13:02:20 -08:00
2022-03-22 15:57:11 -07:00
2022-10-11 12:01:24 +02:00
2022-11-08 15:57:24 -08:00
2023-07-17 16:05:19 -07:00
2021-07-08 11:48:20 -07:00
2021-12-28 11:26:18 +01:00
2024-02-23 09:24:58 +01:00
2023-08-21 13:46:25 -07:00
2021-05-19 15:05:11 +02:00
2023-09-09 15:11:49 -07:00
2023-04-17 18:01:23 +02:00
2021-08-13 18:37:38 +02:00
2023-08-15 14:57:25 -07:00
2021-07-08 11:48:20 -07:00
2023-03-31 09:21:35 -06:00
2022-11-18 13:55:06 -08:00
2023-07-26 12:29:13 +02:00
2023-01-13 14:35:38 -06:00
2022-03-11 10:42:56 +01:00
2023-08-24 16:20:18 -07:00
2022-11-22 19:38:39 -07:00
2023-09-09 15:11:49 -07:00
2024-01-05 15:19:43 +01:00
2024-03-26 18:19:18 -04:00
2020-09-26 10:33:57 -07:00
2023-06-06 13:18:32 +02:00
2024-03-06 14:48:34 +00:00
2023-08-18 10:19:00 -07:00
2023-08-18 10:18:55 -07:00
2021-12-24 14:54:29 -08:00
2022-11-18 13:55:06 -08:00
2022-10-03 17:34:32 -07:00
2023-05-26 13:52:19 -07:00
2023-03-09 23:08:04 -08:00
2021-04-16 16:10:37 -07:00
2023-03-02 21:54:22 -08:00
2024-04-03 15:28:17 +02:00
2023-08-25 08:06:53 -07:00
2022-11-30 13:16:40 -08:00
2022-05-22 11:32:30 -07:00
2023-08-21 13:07:22 -07:00
2023-06-12 11:31:50 -07:00
2022-10-11 17:42:58 -06:00
2022-08-24 13:46:57 +01:00
2023-04-18 16:39:33 -07:00
2023-03-28 10:39:29 +02:00
2023-06-05 15:28:42 -07:00
2021-07-08 11:48:20 -07:00
2022-12-09 10:42:56 +00:00
2023-07-21 11:40:20 -06:00
2023-09-19 13:21:33 -07:00
2023-04-25 21:03:14 -04:00
2022-09-23 16:46:19 +02:00
2022-11-01 10:04:52 -07:00
2022-06-03 10:34:34 -07:00
2022-12-12 16:42:57 -08:00
2022-07-17 17:31:41 -07:00
2022-03-17 20:17:18 -07:00
2023-03-28 16:20:13 -07:00
2023-02-10 17:32:37 -08:00
2023-05-16 14:08:02 -07:00
2023-08-04 18:21:50 -07:00
2023-06-01 11:24:50 -07:00
2022-04-19 21:58:47 +02:00
2022-04-19 21:58:47 +02:00
2022-11-01 10:04:52 -07:00
2021-06-18 11:43:09 +02:00
2023-07-18 13:25:37 -07:00
2021-07-08 11:48:20 -07:00
2020-08-12 10:58:00 -07:00
2024-03-26 18:19:26 -04:00
2023-08-18 17:08:42 +02:00
2022-09-07 17:04:49 +02:00
2023-06-15 13:42:18 +02:00
2023-06-06 21:39:55 +09:00
2021-01-18 11:03:26 +01:00
2022-07-17 17:14:36 -07:00
2022-01-20 08:52:54 +02:00
2022-11-18 02:18:02 +01:00
2022-10-12 18:51:50 -07:00
2023-08-18 10:18:50 -07:00
2024-01-20 11:51:46 +01:00
2023-01-25 14:07:21 -08:00
2023-02-21 08:52:42 +09:00
2022-11-16 13:32:32 +00:00
2022-11-18 02:15:15 +01:00
2022-02-25 09:36:06 +01:00
2023-10-18 12:12:41 -07:00
2023-08-18 10:12:32 -07:00
2022-10-11 17:42:58 -06:00
2022-10-11 17:42:58 -06:00
2023-08-21 13:46:24 -07:00
2023-06-05 15:28:42 -07:00
2022-12-13 15:47:48 -08:00
2023-08-16 11:47:29 +02:00
2021-09-08 11:50:26 -07:00
2022-04-29 14:38:00 -07:00
2023-06-18 02:32:54 -07:00
2022-01-20 08:52:55 +02:00
2023-06-12 11:31:51 -07:00
2022-03-28 19:25:11 -04:00
2023-04-08 13:45:39 -07:00
2021-02-17 14:08:01 +01:00
2022-11-21 22:02:10 +01:00
2023-07-27 13:45:51 +02:00
2020-11-18 14:15:17 -06:00
2023-05-30 16:42:01 -07:00
2023-05-30 16:42:01 -07:00
2023-02-21 14:45:22 -08:00
2022-10-11 17:42:58 -06:00
2024-01-01 12:42:46 +00:00
2023-01-11 16:14:21 -08:00
2023-09-05 19:01:38 -04:00
2020-08-12 10:58:00 -07:00