HIGH
spi Controller Teardown UAF
CVE-2026-31485
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
KernelScan AI7.8HIGH
01Description
In the Linux kernel, the following vulnerability has been resolved: spi: spi-fsl-lpspi: fix teardown order issue (UAF) There is a teardown order issue in the driver. The SPI controller is registered using devm_spi_register_controller(), which delays unregistration of the SPI controller until after the fsl_lpspi_remove() function returns. As the fsl_lpspi_remove() function synchronously tears down the DMA channels, a running SPI transfer triggers the following NULL pointer dereference due to use after free: | fsl_lpspi 42550000.spi: I/O Error in DMA RX | Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 [...] | Call trace: | fsl_lpspi_dma_transfer+0x260/0x340 [spi_fsl_lpspi] | fsl_lpspi_transfer_one+0x198/0x448 [spi_fsl_lpspi] | spi_transfer_one_message+0x49c/0x7c8 | __spi_pump_transfer_message+0x120/0x420 | __spi_sync+0x2c4/0x520 | spi_sync+0x34/0x60 | spidev_message+0x20c/0x378 [spidev] | spidev_ioctl+0x398/0x750 [spidev] [...] Switch from devm_spi_register_controller() to spi_register_controller() in fsl_lpspi_probe() and add the corresponding spi_unregister_controller() in fsl_lpspi_remove().
02KernelScan AI Analysis
Risk summary
A local attacker with access to SPI devices can trigger a use-after-free condition during device removal, potentially leading to system crashes or privilege escalation. The vulnerability occurs when SPI transfers are active during driver teardown.
Vulnerability analysis
Summary: Use-after-free vulnerability in SPI controller teardown sequence
Root Cause: The driver uses devm_spi_register_controller() which delays SPI controller unregistration until after the remove function completes, but the remove function synchronously tears down DMA channels. This creates a window where ongoing SPI transfers can access freed DMA resources.
Attack Surface: Local attack surface requiring access to SPI devices through spidev interface. Triggered during device removal while SPI transfers are active.
Fix Mechanism: Replace devm_spi_register_controller() with manual spi_register_controller() in probe and add explicit spi_unregister_controller() in remove function to ensure proper teardown ordering.
03Fix Versions
| Branch | Fixed in | Patch commit |
|---|---|---|
| 5.10 | 5.10.253 | fbe6f40caeeb |
| 5.15 | 5.15.203 | ca4483f36ac1 |
| 6.1 | 6.1.168 | e3fd54f8b031 |
| 6.12 | 6.12.80 | d5d01f24bc6f |
| 6.18 | 6.18.21 | e89e2b97253c |
| 6.19 | 6.19.11 | 15650dfbaeeb |
| 6.6 | 6.6.131 | adb25339b661 |
| mainline | 7.0 | b341c1176f2e |