Andrey Ryabinin
0207df4fa1
kernel/memremap, kasan: make ZONE_DEVICE with work with KASAN
KASAN learns about hotadded memory via the memory hotplug notifier.
devm_memremap_pages() intentionally skips calling memory hotplug
notifiers. So KASAN doesn't know anything about new memory added by
devm_memremap_pages(). This causes a crash when KASAN tries to access
non-existent shadow memory:
BUG: unable to handle kernel paging request at ffffed0078000000
RIP: 0010:check_memory_region+0x82/0x1e0
Call Trace:
memcpy+0x1f/0x50
pmem_do_bvec+0x163/0x720
pmem_make_request+0x305/0xac0
generic_make_request+0x54f/0xcf0
submit_bio+0x9c/0x370
submit_bh_wbc+0x4c7/0x700
block_read_full_page+0x5ef/0x870
do_read_cache_page+0x2b8/0xb30
read_dev_sector+0xbd/0x3f0
read_lba.isra.0+0x277/0x670
efi_partition+0x41a/0x18f0
check_partition+0x30d/0x5e9
rescan_partitions+0x18c/0x840
__blkdev_get+0x859/0x1060
blkdev_get+0x23f/0x810
__device_add_disk+0x9c8/0xde0
pmem_attach_disk+0x9a8/0xf50
nvdimm_bus_probe+0xf3/0x3c0
driver_probe_device+0x493/0xbd0
bus_for_each_drv+0x118/0x1b0
__device_attach+0x1cd/0x2b0
bus_probe_device+0x1ac/0x260
device_add+0x90d/0x1380
nd_async_device_register+0xe/0x50
async_run_entry_fn+0xc3/0x5d0
process_one_work+0xa0a/0x1810
worker_thread+0x87/0xe80
kthread+0x2d7/0x390
ret_from_fork+0x3a/0x50
Add kasan_add_zero_shadow()/kasan_remove_zero_shadow() - post mm_init()
interface to map/unmap kasan_zero_page at requested virtual addresses.
And use it to add/remove the shadow memory for hotplugged/unplugged
device memory.
Link: http://lkml.kernel.org/r/[email protected]
Fixes: 41e94a8513 ("add devm_memremap_pages")
Signed-off-by: Andrey Ryabinin <[email protected]>
Reported-by: Dave Chinner <[email protected]>
Reviewed-by: Dan Williams <[email protected]>
Tested-by: Dan Williams <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: Alexander Potapenko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
2018-08-17 16:20:30 -07:00
..
2018-08-15 15:04:25 -07:00
2018-07-20 23:44:35 -07:00
2018-06-15 07:15:28 +09:00
2018-06-12 16:19:22 -07:00
2018-08-14 11:11:52 -07:00
2018-08-14 16:39:13 -07:00
2018-06-08 18:56:02 +09:00
2018-08-13 10:47:26 -07:00
2018-04-17 13:42:48 +02:00
2018-08-15 17:39:07 -07:00
2018-08-14 13:12:24 -07:00
2018-08-15 17:39:07 -07:00
2018-08-13 11:25:07 -07:00
2018-08-14 09:46:06 -07:00
2018-08-13 19:18:02 -07:00
2018-08-15 11:18:53 -07:00
2018-01-04 16:45:09 -08:00
2018-02-06 18:32:44 -08:00
2018-05-18 14:58:22 +02:00
2018-06-28 11:41:02 -04:00
2018-07-18 11:43:36 -04:00
2018-07-17 14:45:08 -04:00
2018-02-23 11:22:22 -05:00
2018-06-19 10:39:54 -04:00
2018-08-15 10:46:54 -07:00
2018-06-24 14:39:47 +02:00
2018-08-14 15:00:00 -07:00
2018-06-07 17:34:37 -07:00
2018-04-27 14:34:51 +02:00
2018-05-16 07:23:35 +02:00
2018-05-16 07:23:35 +02:00
2018-04-02 20:14:51 +02:00
2018-02-21 16:54:06 +01:00
2018-06-21 12:33:19 +02:00
2018-08-17 16:20:30 -07:00
2018-08-06 12:35:20 +02:00
2018-02-06 18:32:46 -08:00
2017-12-14 16:00:49 -08:00
2018-06-07 17:34:39 -07:00
2018-05-15 23:08:33 -07:00
2018-01-08 19:43:15 +01:00
2018-03-20 08:57:17 +01:00
2018-02-01 13:36:15 -08:00
2018-08-02 08:06:54 +09:00
2018-06-15 07:55:24 +09:00
2018-06-15 07:55:24 +09:00
2018-06-12 16:19:22 -07:00
2018-07-16 12:31:57 -07:00
2018-06-21 17:33:42 +02:00
2018-08-13 11:25:07 -07:00
2018-07-18 01:18:05 +09:00
2018-08-17 16:20:30 -07:00
2018-07-16 12:31:57 -07:00
2018-01-05 18:43:00 +11:00
2018-06-14 12:21:18 +09:00
2018-04-11 10:28:37 -07:00
2018-04-03 19:15:32 -07:00
2018-04-11 10:28:39 -07:00
2018-02-06 18:32:46 -08:00
2018-08-06 12:35:20 +02:00
2018-06-15 07:55:24 +09:00
2018-06-08 17:21:52 -07:00
2018-07-10 22:18:52 +02:00
2018-06-06 16:34:00 -07:00
2018-06-10 06:14:01 +02:00
2018-08-07 12:25:30 +02:00
2018-07-03 09:20:44 +02:00
2018-08-03 15:52:10 +02:00
2018-08-13 11:25:07 -07:00
2018-06-10 10:17:09 -07:00
2018-06-19 09:56:27 +02:00
2018-04-16 11:26:49 +02:00
2018-07-16 00:16:29 +02:00
2017-12-17 13:57:15 +01:00
2018-02-06 18:32:46 -08:00
2018-06-21 12:33:05 +02:00
2018-06-25 11:30:10 -07:00
2018-05-28 12:49:51 -04:00
2018-04-05 21:36:27 -07:00
2018-04-02 20:15:59 +02:00
2018-04-02 20:15:30 +02:00
2018-06-07 16:56:28 -04:00
2018-06-12 16:19:22 -07:00
2018-02-22 10:21:02 -08:00
2018-04-11 10:28:35 -07:00
2018-08-03 12:19:08 +02:00
2018-07-15 23:51:19 +02:00
2018-05-18 08:47:13 -07:00
2018-06-12 16:19:22 -07:00