KernelScan.io

HIGH Introduced in 7.0

spi-imx DmaBounceBuffer Overflow

CVE-2026-99164

CVSS 7.8 / 10.0 NVD

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

KernelScan AI7.0HIGH

01

In the Linux kernel, the following vulnerability has been resolved: spi: imx: fix slab corruption from undersized DMA bounce buffers Since commit faa8e404ad8e ("spi: imx: support dynamic burst length for ECSPI DMA mode"), the driver allocates its private DMA TX/RX buffers with kzalloc(dma_len), where dma_len is only rounded up to 4 bytes, but maps, syncs and unmaps them with DMA_CACHE_ALIGNED_LEN(dma_len), i.e. rounded up to the cache line size. As a result, the DMA API operates on memory beyond the end of the allocation. This was observed on a custom i.MX8MP platform with an mcp251xfd CAN controller under heavy RPMSG load, as a series of refcount_t warnings triggered from rpmsg_recv_done() in virtio_rpmsg_bus: refcount_t: addition on 0; use-after-free. refcount_t: underflow; use-after-free. refcount_t: saturated; leaking memory. Leading finally to an "Unable to handle kernel paging request" oops. Reproducing this problem took between 30 minutes and roughly 30 hours under the same workload. Hardware watchpoints on the refcount of a struct rpmsg_endpoint showed it was overwritten from 2 to 1 by __pi_memcpy_generic() in the irq/155-spi2.0 thread. Additionally it was found that a "normal" rpmsg_recv_done() took 11µs +/-2µs from its kref_get to kref_put. In the error case the same sequence took about 215µs +/-10µs. Based on this, an LLM was used to identify the size mismatch fixed here. Allocate the buffers with DMA_CACHE_ALIGNED_LEN(dma_len) so they cover the full mapped length, and use the same length for dma_sync_single_for_cpu() to stay consistent with map and unmap. With this patch applied, the same workload ran for more than 200 hours without the problem reproducing.

02

Engine v0.9.0

Risk summary

A local attacker with access to an i.MX SPI device using DMA mode can trigger heap corruption by initiating transfers with lengths that are 4-byte aligned but not cache-line aligned. This corrupts adjacent kernel slab objects, leading to privilege escalation or kernel panic. The bug requires specific transfer sizes and heap layout conditions, making reliable exploitation difficult but possible under sustained load.

Affecteddrivers/spi/spi-imx.c (spi-imx driver)

Vulnerability analysis

The i.MX SPI driver allocates DMA bounce buffers sized only to the next 4-byte boundary, but the DMA mapping API operates on regions rounded up to the cache line size (typically 32 or 64 bytes). When the DMA controller reads or writes these buffers, it accesses memory past the end of the allocation, corrupting neighboring kernel heap objects. The fix increases the allocation size to match the cache-line-aligned length used by the DMA API, ensuring the mapped region stays within the allocated buffer. The vulnerability is reachable by any local user who can initiate SPI transfers through a device node (e.g., spidev) or a kernel driver using this controller, such as the mcp251xfd CAN driver, on i.MX SoCs with ECSPI hardware.

03

BranchIntroducedFixed inPatch commit
7.27.07.2.132777f6637da0
mainline7.07.359eb22641f0c