KernelScan.io

HIGH

spi Controller Teardown UAF

CVE-2026-31485

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.8HIGH

01

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().

02

Engine v0.2.0

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.

Affecteddrivers/spi/spi-fsl-lpspi.c

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.

03

BranchFixed inPatch commit
5.105.10.253fbe6f40caeeb
5.155.15.203ca4483f36ac1
6.16.1.168e3fd54f8b031
6.126.12.80d5d01f24bc6f
6.186.18.21e89e2b97253c
6.196.19.1115650dfbaeeb
6.66.6.131adb25339b661
mainline7.0b341c1176f2e