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, __spi_map_msg() unmaps
TX but leaves tx_sg_mapped set. If TX mapping fails on a later
transfer, mappings created for earlier transfers remain active.
In both cases, cur_{tx,rx}_dma_dev have not yet been updated because they
are assigned only after every transfer has been mapped. The subsequent
spi_unmap_msg() 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 dma_unmap_sg_attrs() accesses the device before checking the
entry count.
Publish both mapping devices before mapping starts and unwind all
failures through __spi_unmap_msg(). 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.
CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
CVSS Score: 9.8
AV:N - Unauthenticated frames to a network-facing SPI NIC such as ENC28J60 or W5500 cause the driver to call spi_sync() with a multi-transfer command-plus-payload message, which reaches __spi_map_msg() in the SPI core with no local login.
AC:L - The attacker decides when transfers run (packet flood) and can force a partial DMA map failure via memory or IOMMU pressure; controllers such as fsl-lpspi DMA-map even tiny transfers and MUST_TX/MUST_RX dummy buffers create the TX-then-RX failure the bug requires, with no race to win.
PR:N - The SPI Ethernet receive and transmit paths run before any protocol authentication and have no capability, device-node, or namespace check, so a remote sender needs no privileges.
UI:N - Once the SPI NIC is configured and up, attacker traffic alone drives spi_sync() into the mapping path; no separate victim action is required.
S:U - Wrong-device or double DMA unmap and the resulting oops stay inside the host kernel DMA/IOMMU authority and do not cross a VM, guest, or other authorization boundary.
C:H - On partial map failure the core leaves tx_sg_mapped set after unmapping TX, or leaves earlier live mappings active, then spi_unmap_msg() unmaps again with a NULL or stale DMA device, corrupting IOMMU bookkeeping in a way that can expose kernel memory.
I:H - Double-unmap or wrong-device unmap of scatter-gather DMA mappings can alias or tear down IOVAs and allow writes into unintended kernel memory, so integrity impact is high under the required higher-severity rule.
A:H - dma_unmap_sg_attrs() loads the mapping device before checking the SG entry count, so a NULL cur_{tx,rx}_dma_dev (or a NULL sgl on the IOMMU unmap path) causes a repeatable kernel oops.
| Attack Vector |
Network |
Scope |
Unchanged |
| Attack Complexity |
Low |
Confidentiality Impact |
High |
| Privileges Required |
None |
Integrity Impact |
High |
| User Interaction |
None |
Availability Impact |
High |
AV:N - Unauthenticated frames to a network-facing SPI NIC such as ENC28J60 or W5500 cause the driver to call spi_sync() with a multi-transfer command-plus-payload message, which reaches __spi_map_msg() in the SPI core with no local login.
AC:L - The attacker decides when transfers run (packet flood) and can force a partial DMA map failure via memory or IOMMU pressure; controllers such as fsl-lpspi DMA-map even tiny transfers and MUST_TX/MUST_RX dummy buffers create the TX-then-RX failure the bug requires, with no race to win.
PR:N - The SPI Ethernet receive and transmit paths run before any protocol authentication and have no capability, device-node, or namespace check, so a remote sender needs no privileges.
UI:N - Once the SPI NIC is configured and up, attacker traffic alone drives spi_sync() into the mapping path; no separate victim action is required.
S:U - Wrong-device or double DMA unmap and the resulting oops stay inside the host kernel DMA/IOMMU authority and do not cross a VM, guest, or other authorization boundary.
C:H - On partial map failure the core leaves tx_sg_mapped set after unmapping TX, or leaves earlier live mappings active, then spi_unmap_msg() unmaps again with a NULL or stale DMA device, corrupting IOMMU bookkeeping in a way that can expose kernel memory.
I:H - Double-unmap or wrong-device unmap of scatter-gather DMA mappings can alias or tear down IOVAs and allow writes into unintended kernel memory, so integrity impact is high under the required higher-severity rule.
A:H - dma_unmap_sg_attrs() loads the mapping device before checking the SG entry count, so a NULL cur_{tx,rx}_dma_dev (or a NULL sgl on the IOMMU unmap path) causes a repeatable kernel oops.
CVSS 3.1