CVE-2026-99714: nvme: Do not drop the cdev reference twice when cdev_device_add() fails
From: Greg Kroah-Hartman <[email protected]>
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
nvme: Do not drop the cdev reference twice when cdev_device_add() fails
Since commit 9952f3882ecb ("nvme: fix cdev lifetime"), nvme_add_ns_cdev() and nvme_add_ns_head_cdev() take a reference to the namespace (or namespace head) before calling nvme_cdev_add(), to be dropped by the char device's release, nvme_cdev_rel(), and drop it themselves when nvme_cdev_add() fails. But when cdev_device_add() fails, nvme_cdev_add() has already put the device, and nvme_cdev_rel() has already dropped that reference: the caller drops it a second time.
With one allocation failure injected into cdev_device_add() for a namespace on an NVMe over loop controller, deleting the controller gives, with native multipath:
BUG: KASAN: slab-use-after-free in nvme_put_ns_head+0x21/0x140 Write of size 4 at addr ff1100000a4ea078 by task init/1 nvme_put_ns_head nvme_put_ns nvme_remove_namespaces nvme_do_delete_ctrl nvme_delete_ctrl_sync nvme_sysfs_delete Freed by task 1: kfree nvme_ns_remove nvme_remove_namespaces refcount_t: underflow; use-after-free.
Take the reference in nvme_cdev_add() instead, right before cdev_device_add(), and let the callers neither take nor drop it. Add nvme_is_ns_cdev() for the check that nvme_cdev_rel() and nvme_cdev_add() now share.
The Linux kernel CVE team has assigned CVE-2026-99714 to this issue.
Affected and fixed versions
===========================
Issue introduced in 7.3 with commit 9952f3882ecba709092379b71e02b09762b26f96 and fixed in 7.3.5 with commit 45d0c2d7d338ae1606984ed92d254ca0efcef921 Issue introduced in 7.3 with commit 9952f3882ecba709092379b71e02b09762b26f96 and fixed in 7.4-rc2 with commit 7dfe79db5615df8d37ae7de6d3ec099b71bf3e03 Issue introduced in 7.2.10 with commit 98b09ad7934482e64db4b4477d91e3bbf43adf4c
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2026-99714
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
drivers/nvme/host/core.c
drivers/nvme/host/multipath.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/45d0c2d7d338ae1606984ed92d254ca0efcef921 https://git.kernel.org/stable/c/7dfe79db5615df8d37ae7de6d3ec099b71bf3e03