CVE-2026-98520: drm/amdkfd: fix use-after-free and multi-container gap in kfd_dev_mapping
In the Linux kernel, the following vulnerability has been resolved:
drm/amdkfd: fix use-after-free and multi-container gap in kfddevmapping
kfddevmapping caches the addressspace of the first /dev/kfd opener so that the GPU reset path can call unmapmappingrange() to zap all userspace mappings of doorbell and MMIO ranges. This design has two bugs that both manifest under SRIOV with multiple containers:
1. Use-after-free / rwsem deadlock. The cached pointer refers to an inode owned by the first opener's container. When that container exits and its inode is released, kfddevmapping becomes a dangling pointer. A subsequent GPU reset dereferences it inside unmapmappingrange(), which takes immaprwsem on the freed inode, causing a hard hang observable as an uninterruptible rwsem wait.
2. Multi-container gap. Only the first opener's addressspace is cached; VMAs created by later openers live in a different addressspace and are never reached by unmapmappingrange(). After a GPU reset those stale mappings keep doorbell and MMIO pages accessible to guest userspace with no GPU behind them, risking PCIe transaction timeouts and NMI panics.
Fix both bugs with the same approach used by DRM core (drmdrv.c): create a private pseudo-filesystem at module init time and allocate one anonymous inode from it. In kfdopen() redirect every opener's file->fmapping to that inode's addressspace. The inode is module-owned, lives exactly as long as the amdgpu module, and collects VMAs from all openers in one addressspace. A single unmapmappingrange() call in the reset path then correctly reaches every container's mappings with no dangling pointer risk.
The hang manifests as an NMI backtrace on the GPU reset workqueue stuck spinning in rwsemdownreadslowpath() with a corrupted immaprwsem:
Workqueue: amdgpu-reset-dev xgpuaimailboxflrwork [amdgpu] Call Trace: <TASK> kvmwait+0x1f/0x40 pvqueuedspinlockslowpath+0x31d/0x3a0 rawspinlockirq+0x51/0x80 rwsemdownreadslowpath+0xb3/0x550 downread+0x48/0xd0 unmapmappingrange+0x71/0x140 kfddevunmapmappingrange+0x5b/0x140 [amdgpu] amdgpuamdkfdclearkfdmapping+0xd8/0x190 [amdgpu] amdgpudevicegpurecover+0x232/0x450 [amdgpu] xgpuaimailboxflrwork+0xb5/0xc0 [amdgpu] processonework+0x18e/0x3e0 workerthread+0x2e3/0x420 kthread+0x10a/0x230
(cherry picked from commit 1128b4a52de1572e87431de837fd9850cb99542c)
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Patch 1128b4a52de1572e87431de837fd9850cb99542c