CVE-2026-90012: spi: Fix DMA mapping ownership on partial map failure
In the Linux kernel, the following vulnerability has been resolved:
spi: Fix DMA mapping ownership on partial map failure
If RX mapping fails after TX mapping succeeds, spimapmsg() unmaps TX but leaves txsgmapped set. If TX mapping fails on a later transfer, mappings created for earlier transfers remain active.
In both cases, cur{tx,rx}dmadev have not yet been updated because they are assigned only after every transfer has been mapped. The subsequent spiunmapmsg() may therefore unmap the TX mapping again or release earlier mappings using a NULL or stale device. Using a NULL device can trigger an oops. An empty SG table does not prevent the NULL dereference because dmaunmapsgattrs() accesses the device before checking the entry count.
Publish both mapping devices before mapping starts and unwind all failures through spiunmapmsg(). This clears the mapping flags and releases each mapping once with the device that created it.
Publishing the devices before the loop also refreshes them when no transfer needs mapping. No mapping flag is set in that case, so current users do not use the pointers as mapping owners.
Event History
Frequently Asked Questions
What runtime conditions can lead to incorrect DMA cleanup?
The problematic paths occur when RX DMA mapping fails after TX mapping has succeeded, or when TX mapping fails on a later transfer after earlier transfers were mapped. In these cases, cleanup can use mapping state or device pointers that do not correctly reflect the mappings created.
What is the practical impact of the faulty cleanup?
A TX mapping may be unmapped twice, or earlier mappings may be released using a NULL or stale DMA device. Using a NULL device can trigger a kernel oops, including when the scatter-gather table is empty because the DMA unmap routine accesses the device before checking the entry count.
Are transfers that do not require DMA mapping affected by mapping ownership flags?
No mapping flag is set when no transfer requires mapping, so current users do not use the published device pointers as mapping owners in that case. The fix still refreshes the device pointers before mapping begins.