Skip to contentSkip to conversation

CVE-2026-31487: spi: use generic driver_override infrastructure

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Apr 22

lore
Share & tools
lore
#0 lore raw

From: Greg Kroah-Hartman <[email protected]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

spi: use generic driver_override infrastructure

When a driver is probed through __driver_attach(), the bus' match() callback is called without the device lock held, thus accessing the driver_override field without a lock, which can cause a UAF.

Fix this by using the driver-core driver_override infrastructure taking care of proper locking internally.

Note that calling match() from __driver_attach() without the device lock held is intentional. [1]

Also note that we do not enable the driver_override feature of struct bus_type, as SPI - in contrast to most other buses - passes "" to sysfs_emit() when the driver_override pointer is NULL. Thus, printing "\n" instead of "(null)\n".

The Linux kernel CVE team has assigned CVE-2026-31487 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 4.20 with commit 5039563e7c25eccd7fec1de6706011009d1c5665 and fixed in 6.12.80 with commit eedf220442d13b6d97294e5b0ac8a2c38ee1a1a0
	Issue introduced in 4.20 with commit 5039563e7c25eccd7fec1de6706011009d1c5665 and fixed in 6.18.21 with commit c73a58661a760373d08a6883af4f0bb5cc991a67
	Issue introduced in 4.20 with commit 5039563e7c25eccd7fec1de6706011009d1c5665 and fixed in 6.19.11 with commit e0ae367a2de06c49aa1de6ec9b1ab6860bbb2cf0
	Issue introduced in 4.20 with commit 5039563e7c25eccd7fec1de6706011009d1c5665 and fixed in 7.0 with commit cc34d77dd48708d810c12bfd6f5bf03304f6c824

Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at

	https://cve.org/CVERecord/?id=CVE-2026-31487

will be updated if fixes are backported, please check that for the most up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
drivers/spi/spi.c
include/linux/spi/spi.h

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:

	https://git.kernel.org/stable/c/eedf220442d13b6d97294e5b0ac8a2c38ee1a1a0
	https://git.kernel.org/stable/c/c73a58661a760373d08a6883af4f0bb5cc991a67
	https://git.kernel.org/stable/c/e0ae367a2de06c49aa1de6ec9b1ab6860bbb2cf0
	https://git.kernel.org/stable/c/cc34d77dd48708d810c12bfd6f5bf03304f6c824