Skip to content

nvme: Fix potential gendisk leak in nvme_alloc_ns - #33

Open
ghost wants to merge 1 commit into
for-next_basefrom
series/1203581=>for-next
Open

ghost wants to merge 1 commit into
for-next_basefrom
series/1203581=>for-next

Conversation

@ghost

@ghost ghost commented Nov 10, 2026

Copy link
Copy Markdown

Pull request for series with
subject: nvme: Fix potential gendisk leak in nvme_alloc_ns
version: 1
url: https://patchwork.kernel.org/series/1203581/

@ghost

ghost commented Nov 10, 2026

Copy link
Copy Markdown
Author

Upstream branch: de52810
series: https://patchwork.kernel.org/series/1203581/
version: 1

@ghost
ghost force-pushed the for-next_base branch from 8c33852 to 18eb5ad Compare November 10, 2026 10:19
@ghost

ghost commented Nov 10, 2026

Copy link
Copy Markdown
Author

Upstream branch: de52810
series: https://patchwork.kernel.org/series/1203581/
version: 1

Multiple BUGs were seen after the following sequence:
1) ctrl A in subsys A allocs ns nvmeAcAn1 and ns_head nvmeAn1 and sets
   both as live
2) ctrl B in subsys A allocs ns nvmeAcBn1 under ns_head nvmeAn1, but is
   interrupted or stalled between nvme_init_ns_head and healthy return
3) the namespace is removed from subsystem, triggering rescan
4) nvmeAcAn1 completes nvme_ns_remove
5) nvmeAcBn1 allocation returns through an error pathway in nvme_alloc_ns

In this sequence, when nvmeAcBn1 returns, it is the last path and has the
responsibility of shutting down the live ns_head, but does not call
nvme_mpath_shutdown_disk. Failure to call nvme_mpath_shutdown_disk leaves
the gendisk active in sysfs/devfs while components around it are freed.
The result is that a new nvme_ns_head with the same namespace number
cannot be created in sysfs and freed memory can be accessed through
remaining userspace files. Most observed panics were seen from paths
utilizing nvme_find_path, such as nuse_show or blkdev_ioctl, though
occasionally corruption of the dpm list was detected as well.

Fix here is to simply keep ns_head cleanup the same as nvme_ns_remove.
This ensures we don't break delayed removal and that we clean up the
gendisk when appropriate.

Signed-off-by: Kyle Smith <kyles@hpe.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
@ghost
ghost force-pushed the series/1203581=>for-next branch from 8e79a13 to 17dcf72 Compare November 10, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant