Zheyu Ma
cad55afe37
memstick: r592: Fix a UAF bug when removing the driver
[ Upstream commit 738216c1953e802aa9f930c5d15b8f9092c847ff ]
In r592_remove(), the driver will free dma after freeing the host, which
may cause a UAF bug.
The following log reveals it:
[ 45.361796 ] BUG: KASAN: use-after-free in r592_remove+0x269/0x350 [r592]
[ 45.364286 ] Call Trace:
[ 45.364472 ] dump_stack_lvl+0xa8/0xd1
[ 45.364751 ] print_address_description+0x87/0x3b0
[ 45.365137 ] kasan_report+0x172/0x1c0
[ 45.365415 ] ? r592_remove+0x269/0x350 [r592]
[ 45.365834 ] ? r592_remove+0x269/0x350 [r592]
[ 45.366168 ] __asan_report_load8_noabort+0x14/0x20
[ 45.366531 ] r592_remove+0x269/0x350 [r592]
[ 45.378785 ]
[ 45.378903 ] Allocated by task 4674:
[ 45.379162 ] ____kasan_kmalloc+0xb5/0xe0
[ 45.379455 ] __kasan_kmalloc+0x9/0x10
[ 45.379730 ] __kmalloc+0x150/0x280
[ 45.379984 ] memstick_alloc_host+0x2a/0x190
[ 45.380664 ]
[ 45.380781 ] Freed by task 5509:
[ 45.381014 ] kasan_set_track+0x3d/0x70
[ 45.381293 ] kasan_set_free_info+0x23/0x40
[ 45.381635 ] ____kasan_slab_free+0x10b/0x140
[ 45.381950 ] __kasan_slab_free+0x11/0x20
[ 45.382241 ] slab_free_freelist_hook+0x81/0x150
[ 45.382575 ] kfree+0x13e/0x290
[ 45.382805 ] memstick_free+0x1c/0x20
[ 45.383070 ] device_release+0x9c/0x1d0
[ 45.383349 ] kobject_put+0x2ef/0x4c0
[ 45.383616 ] put_device+0x1f/0x30
[ 45.383865 ] memstick_free_host+0x24/0x30
[ 45.384162 ] r592_remove+0x242/0x350 [r592]
[ 45.384473 ] pci_device_remove+0xa9/0x250
Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
Link: https://lore.kernel.org/r/1634383581-11055-1-git-send-email-zheyuma97@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-11-18 14:03:58 +01:00
..
2021-11-18 14:03:57 +01:00
2021-11-06 14:10:09 +01:00
2021-11-18 14:03:36 +01:00
2021-11-18 14:03:46 +01:00
2021-07-19 09:44:52 +02:00
2021-11-18 14:03:46 +01:00
2021-09-15 09:50:45 +02:00
2021-09-16 12:51:23 +02:00
2021-09-03 10:09:28 +02:00
2021-10-20 11:45:01 +02:00
2021-05-26 12:06:55 +02:00
2021-11-18 14:03:56 +01:00
2021-10-20 11:44:58 +02:00
2021-09-15 09:50:29 +02:00
2021-09-15 09:50:38 +02:00
2021-10-06 15:55:46 +02:00
2021-09-18 13:40:12 +02:00
2021-11-18 14:03:38 +01:00
2021-07-14 16:56:11 +02:00
2021-09-26 14:09:00 +02:00
2021-11-18 14:03:52 +01:00
2021-11-18 14:03:45 +01:00
2021-07-19 09:45:00 +02:00
2021-11-18 14:03:38 +01:00
2021-09-30 10:11:04 +02:00
2021-07-20 16:05:42 +02:00
2021-11-18 14:03:42 +01:00
2021-11-18 14:03:57 +01:00
2021-10-17 10:43:32 +02:00
2021-11-18 14:03:42 +01:00
2021-11-18 14:03:44 +01:00
2021-11-18 14:03:51 +01:00
2021-10-13 10:04:29 +02:00
2021-11-18 14:03:51 +01:00
2021-11-18 14:03:47 +01:00
2021-11-18 14:03:36 +01:00
2021-09-30 10:11:04 +02:00
2021-09-26 14:08:59 +02:00
2021-10-06 15:56:01 +02:00
2021-10-09 14:40:57 +02:00
2021-11-18 14:03:41 +01:00
2021-09-15 09:50:36 +02:00
2021-09-18 13:40:16 +02:00
2021-09-30 10:11:00 +02:00
2021-11-18 14:03:57 +01:00
2021-11-18 14:03:56 +01:00
2021-11-18 14:03:47 +01:00
2021-11-18 14:03:58 +01:00
2021-09-22 12:28:06 +02:00
2021-10-20 11:45:01 +02:00
2021-11-18 14:03:57 +01:00
2021-11-18 14:03:51 +01:00
2021-11-18 14:03:48 +01:00
2021-11-18 14:03:57 +01:00
2021-11-02 19:48:19 +01:00
2021-09-22 12:28:02 +02:00
2021-09-18 13:40:36 +02:00
2021-11-18 14:03:43 +01:00
2021-10-20 11:45:01 +02:00
2021-09-18 13:40:31 +02:00
2021-09-18 13:40:29 +02:00
2021-09-26 14:08:59 +02:00
2021-09-18 13:40:34 +02:00
2021-11-18 14:03:50 +01:00
2021-08-12 13:22:16 +02:00
2021-07-14 16:56:08 +02:00
2021-07-20 16:05:46 +02:00
2021-11-18 14:03:51 +01:00
2021-11-18 14:03:53 +01:00
2021-11-18 14:03:52 +01:00
2021-10-13 10:04:27 +02:00
2021-09-26 14:09:01 +02:00
2021-05-26 12:06:52 +02:00
2021-11-18 14:03:45 +01:00
2021-07-20 16:05:50 +02:00
2021-11-18 14:03:42 +01:00
2021-09-26 14:09:02 +02:00
2021-09-30 10:11:03 +02:00
2021-11-18 14:03:41 +01:00
2021-08-26 08:35:55 -04:00
2021-11-18 14:03:48 +01:00
2021-09-18 13:40:31 +02:00
2021-11-18 14:03:43 +01:00
2021-07-14 16:56:21 +02:00
2021-11-18 14:03:56 +01:00
2021-09-30 10:11:03 +02:00
2021-10-20 11:45:02 +02:00
2021-10-09 14:40:57 +02:00
2021-09-18 13:40:27 +02:00
2021-11-18 14:03:51 +01:00
2021-05-26 12:06:52 +02:00
2021-11-18 14:03:52 +01:00
2021-08-26 08:35:42 -04:00
2021-09-18 13:40:12 +02:00
2021-10-20 11:45:04 +02:00
2021-10-13 10:04:28 +02:00
2021-10-20 11:45:01 +02:00
2021-07-14 16:56:41 +02:00
2021-07-20 16:05:39 +02:00
2021-11-18 14:03:43 +01:00
2021-11-18 14:03:49 +01:00