Use-after-free vulnerability in spi package
Summary
GSD-2021-1000385: spi: Fix use-after-free with devm_spi_alloc_*. Affects Kernel versions >= 5e844cc37a5cbaa460e68f9a989d321d63088a89, < c7fabe372a9031acd00498bc718ce27c253abfd1. No fix is published. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The spi package is a part of the Linux Kernel ecosystem and is responsible for providing support for Serial Peripheral Interface (SPI) devices. SPI is a synchronous serial communication interface commonly used for connecting microcontrollers, sensors, and other peripheral devices to a central processing unit (CPU). The spi package in the Linux Kernel allows applications to interact with SPI devices by providing a set of APIs and drivers. However, a use-after-free vulnerability has been discovered in the spi package, which could potentially lead to security breaches and system instability.
Vulnerability Detail
The use-after-free vulnerability in the spi package occurs when the devm_spi_alloc_* functions are used. These functions allocate memory for a SPI device and register it with the SPI subsystem. However, due to a programming error, the memory allocated for the device is freed prematurely, leading to a use-after-free condition. An attacker could potentially exploit this vulnerability by manipulating the freed memory to execute arbitrary code or cause a denial-of-service (DoS) condition. The impact and attack plausibility of this vulnerability have not been proven yet.
How To Fix
No fixed version is published for this vulnerability.
Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →
Workaround
As a workaround, users can avoid using the devm_spi_alloc_* functions and instead manually allocate and register SPI devices using other APIs provided by the spi package. By bypassing the vulnerable functions, the risk of encountering the use-after-free vulnerability can be mitigated. Here is an example of how to manually allocate and register a SPI device:
#include <linux/spi/spi.h>
struct spi_device *spi_dev;
spi_dev = spi_alloc_device(spi_master);
if (!spi_dev) {
// Handle error
}
spi_dev->modalias = "spi_device_driver";
spi_dev->max_speed_hz = 1000000;
ret = spi_add_device(spi_dev);
if (ret) {
spi_dev_put(spi_dev);
// Handle error
}
By following this approach, the use-after-free vulnerability can be avoided.
Conclusion
The use-after-free vulnerability in the spi package of the Linux Kernel can potentially lead to security breaches and system instability. It is crucial to update the Linux Kernel to version v5.10.37 or later to fix this vulnerability. Alternatively, users can follow the provided workaround to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for Kernel →
FAQ
The spi package is a component of the Linux Kernel ecosystem that provides support for Serial Peripheral Interface (SPI) devices. SPI is a synchronous serial communication interface commonly used for connecting microcontrollers, sensors, and other peripheral devices to a central processing unit (CPU). The spi package in the Linux Kernel allows applications to interact with SPI devices by providing a set of APIs and drivers.
A use-after-free vulnerability is a type of memory corruption issue that occurs when a program continues to use a memory region after it has been freed. This can lead to various security vulnerabilities, including the execution of arbitrary code or a denial-of-service (DoS) condition.
An attacker can potentially exploit this vulnerability by manipulating the freed memory to execute arbitrary code or cause a denial-of-service (DoS) condition. By carefully crafting malicious input, an attacker can trigger the use-after-free condition and gain control over the affected system.
No, the impact and attack plausibility of this vulnerability have not been proven yet. However, it is important to apply the recommended fix or workaround to mitigate any potential risks.
To fix this vulnerability, it is recommended to update the Linux Kernel to version v5.10.37 or later. The fix for this vulnerability was implemented in commit c7fabe372a9031acd00498bc718ce27c253abfd1, which is included in Linux Kernel version v5.10.37. Updating to the latest version of the Linux Kernel ensures that the vulnerable code is replaced with the patched code, eliminating the use-after-free vulnerability.
Related vulnerabilities
Recent vulnerabilities recorded for Kernel.