linux/drivers/nvdimm
Ira Weiny a8aec14230 nvdimm/bus: Fix potential use after free in asynchronous initialization
Dingisoul with KASAN reports a use after free if device_add() fails in
nd_async_device_register().

Commit b6eae0f61d ("libnvdimm: Hold reference on parent while
scheduling async init") correctly added a reference on the parent device
to be held until asynchronous initialization was complete.  However, if
device_add() results in an allocation failure the ref count of the
device drops to 0 prior to the parent pointer being accessed.  Thus
resulting in use after free.

The bug bot AI correctly identified the fix.  Save a reference to the
parent pointer to be used to drop the parent reference regardless of the
outcome of device_add().

Reported-by: Dingisoul <dingiso.kernel@gmail.com>
Closes: http://lore.kernel.org/8855544b-be9e-4153-aa55-0bc328b13733@gmail.com
Fixes: b6eae0f61d ("libnvdimm: Hold reference on parent while scheduling async init")
Cc: stable@vger.kernel.org
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://patch.msgid.link/20260306-fix-uaf-async-init-v1-1-a28fd7526723@intel.com
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
2026-03-09 09:38:22 -05:00
..
Kconfig nvdimm: allow exposing RAM carveouts as NVDIMM DIMM devices 2025-11-03 14:50:42 -06:00
Makefile nvdimm: allow exposing RAM carveouts as NVDIMM DIMM devices 2025-11-03 14:50:42 -06:00
badrange.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
btt.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
btt.h nvdimm-btt: convert to blk_alloc_disk/blk_cleanup_disk 2021-06-01 07:42:23 -06:00
btt_devs.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
bus.c nvdimm/bus: Fix potential use after free in asynchronous initialization 2026-03-09 09:38:22 -05:00
claim.c nvdimm: Introduce guard() for nvdimm_bus_lock 2025-09-25 12:40:11 -05:00
core.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
dax_devs.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
dimm.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
dimm_devs.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
e820.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
label.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
label.h nvdimm/region: Delete nd_blk_region infrastructure 2022-03-11 15:53:13 -08:00
namespace_devs.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
nd-core.h libnvdimm: Remove unused nd_attach_ndns 2025-03-03 08:03:43 -06:00
nd.h nvdimm: Introduce guard() for nvdimm_bus_lock 2025-09-25 12:40:11 -05:00
nd_perf.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
nd_virtio.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
of_pmem.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
pfn.h libnvdimm/namespace: Enforce memremap_compat_align() 2020-03-17 12:23:21 -07:00
pfn_devs.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
pmem.c drivers/nvdimm: Use local kmaps 2026-01-26 12:04:55 -06:00
pmem.h mm: remove callers of pfn_t functionality 2025-07-09 22:42:19 -07:00
ramdax.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
region.c standalone cache drivers for v6.19 2025-11-27 23:00:45 +01:00
region_devs.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
security.c nvdimm: replace use of system_wq with system_percpu_wq 2025-11-05 15:48:11 -06:00
virtio_pmem.c nvdimm: virtio_pmem: serialize flush requests 2026-02-04 13:16:40 -06:00
virtio_pmem.h nvdimm: virtio_pmem: serialize flush requests 2026-02-04 13:16:40 -06:00