CVE-2026-139787: nvme-tcp: fix use-after-free in nvme_tcp_free_ctrl()
In the Linux kernel, the following vulnerability has been resolved:
nvme-tcp: fix use-after-free in nvmetcpfreectrl()
nvmetcpfreectrl() reads ctrl->ctrl.opts to know how many queue mutexes to destroy. When creating the controller fails, nvmfcreatectrl() frees opts as soon as nvmetcpcreatectrl() returns, but a concurrent open of the character device can hold the last reference to the controller. With CONFIGDEBUGKOBJECTRELEASE, which delays the release, every failed connect reads freed memory:
BUG: KASAN: slab-use-after-free in nvmetcpfreectrl+0x38b/0x430 Read of size 4 at addr ffff888005b93740 by task kworker/2:1/51
Keep the size of the queue array in the controller and use it instead.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In nvme-tcp, keep the queue-array size in the controller and use that stored size instead of reading ctrl->ctrl.opts after the options may have been freed.
Event History
Frequently Asked Questions
What runtime conditions are needed for this issue to occur?
Controller creation must fail, and a concurrent open of the character device must retain the controller's last reference after nvme_tcp_create_ctrl() returns. The subsequent controller release can then access options memory that was already freed.
Does CONFIG_DEBUG_KOBJECT_RELEASE affect exposure?
Yes. Because it delays object release, the report states that with CONFIG_DEBUG_KOBJECT_RELEASE enabled, every failed connect reads freed memory during controller cleanup.
How might an affected system be identified?
The reported symptom is a KASAN slab-use-after-free in nvme_tcp_free_ctrl(), caused by a read of freed memory during cleanup of a failed NVMe/TCP controller connection.