linux/drivers/nvdimm
Dan Williams a624eb5203 libnvdimm/pmem: Fix blk_cleanup_disk() usage
The queue_to_disk() helper can not be used after del_gendisk()
communicate @disk via the pgmap->owner.

Otherwise, queue_to_disk() returns NULL resulting in the splat below.

 Kernel attempted to read user page (330) - exploit attempt? (uid: 0)
 BUG: Kernel NULL pointer dereference on read at 0x00000330
 Faulting instruction address: 0xc000000000906344
 Oops: Kernel access of bad area, sig: 11 [#1]
 [..]
 NIP [c000000000906344] pmem_pagemap_cleanup+0x24/0x40
 LR [c0000000004701d4] memunmap_pages+0x1b4/0x4b0
 Call Trace:
 [c000000022cbb9c0] [c0000000009063c8] pmem_pagemap_kill+0x28/0x40 (unreliable)
 [c000000022cbb9e0] [c0000000004701d4] memunmap_pages+0x1b4/0x4b0
 [c000000022cbba90] [c0000000008b28a0] devm_action_release+0x30/0x50
 [c000000022cbbab0] [c0000000008b39c8] release_nodes+0x2f8/0x3e0
 [c000000022cbbb60] [c0000000008ac440] device_release_driver_internal+0x190/0x2b0
 [c000000022cbbba0] [c0000000008a8450] unbind_store+0x130/0x170

Reported-by: Sachin Sant <sachinp@linux.vnet.ibm.com>
Fixes: 87eb73b2ca ("nvdimm-pmem: convert to blk_alloc_disk/blk_cleanup_disk")
Link: http://lore.kernel.org/r/DFB75BA8-603F-4A35-880B-C5B23EF8FA7D@linux.vnet.ibm.com
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: Sachin Sant <sachinp@linux.vnet.ibm.com>
Link: https://lore.kernel.org/r/162310994435.1571616.334551212901820961.stgit@dwillia2-desk3.amr.corp.intel.com
[axboe: fold in compile warning fix]
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-06-09 09:09:22 -06:00
..
badrange.c mm/memremap_pages: convert to 'struct range' 2020-10-13 18:38:28 -07:00
blk.c nvdimm-blk: convert to blk_alloc_disk/blk_cleanup_disk 2021-06-01 07:42:23 -06:00
btt.c nvdimm-btt: convert to blk_alloc_disk/blk_cleanup_disk 2021-06-01 07:42:23 -06:00
btt.h nvdimm-btt: convert to blk_alloc_disk/blk_cleanup_disk 2021-06-01 07:42:23 -06:00
btt_devs.c libnvdimm: Move attribute groups to device type 2019-11-17 09:17:38 -08:00
bus.c libnvdimm: Notify disk drivers to revalidate region read-only 2021-04-08 22:18:36 -07:00
claim.c libnvdimm: Cleanup include of badblocks.h 2020-12-15 21:47:45 -08:00
core.c libnvdimm: Cleanup include of badblocks.h 2020-12-15 21:47:45 -08:00
dax_devs.c libnvdimm: Move attribute groups to device type 2019-11-17 09:17:38 -08:00
dimm.c libnvdimm: Make remove callback return void 2021-02-16 19:35:29 -08:00
dimm_devs.c libnvdimm/dimm: Avoid race between probe and available_slots_show() 2021-02-01 16:20:40 -08:00
e820.c libnvdimm/e820: Retrieve and populate correct 'target_node' info 2020-02-18 10:28:05 -08:00
Kconfig lib: Uplevel the pmem "region" ida to a global allocator 2019-11-07 15:44:29 +01:00
label.c libnvdimm/label: Return -ENXIO for no slot in __blk_label_update 2020-12-16 16:53:00 -08:00
label.h libnvdimm/label: Replace zero-length array with flexible-array member 2020-03-30 12:37:09 -07:00
Makefile libnvdimm: Enable unit test infrastructure compile checks 2019-09-07 04:28:05 -03:00
namespace_devs.c libnvdimm/namespace: Fix visibility of namespace resource attribute 2021-01-28 00:22:34 -08:00
nd-core.h PM, libnvdimm: Add runtime firmware activation support 2020-07-28 19:28:32 -06:00
nd.h mm/memremap_pages: convert to 'struct range' 2020-10-13 18:38:28 -07:00
nd_virtio.c virtio_pmem: fix sparse warning 2019-07-16 19:44:26 -07:00
of_pmem.c powerpc/pmem: Initialize pmem device on newer hardware 2020-07-16 13:00:23 +10:00
pfn.h libnvdimm/namespace: Enforce memremap_compat_align() 2020-03-17 12:23:21 -07:00
pfn_devs.c mm/memremap_pages: support multiple ranges per invocation 2020-10-13 18:38:28 -07:00
pmem.c libnvdimm/pmem: Fix blk_cleanup_disk() usage 2021-06-09 09:09:22 -06:00
pmem.h libnvdimm, pmem: Restore page attributes when clearing errors 2018-08-20 09:22:45 -07:00
region.c libnvdimm: Make remove callback return void 2021-02-16 19:35:29 -08:00
region_devs.c libnvdimm/region: Fix nvdimm_has_flush() to handle ND_REGION_ASYNC 2021-04-09 21:56:01 -07:00
security.c libnvdimm for 5.9 2020-08-11 10:59:19 -07:00
virtio_pmem.c virtio_pmem: convert to LE accessors 2020-08-05 11:08:41 -04:00
virtio_pmem.h virtio-pmem: Add virtio pmem driver 2019-07-05 15:19:10 -07:00