CVE-2021-47195: Vulnerability in Linux Linux
In the Linux kernel, the following vulnerability has been resolved: spi: fix use-after-free of the add_lock mutex Commit 6098475d4cb4 ("spi: Fix deadlock when adding SPI controllers on SPI buses") introduced a per-controller mutex. But mutex_unlock() of said lock is called after the controller is already freed: spi_unregister_controller(ctlr) -> put_device(&ctlr->dev) -> spi_controller_release(dev) -> mutex_unlock(&ctrl->add_lock) Move the put_device() after the mutex_unlock().
AI Analysis
Technical Summary
CVE-2021-47195 is a use-after-free vulnerability in the Linux kernel's SPI (Serial Peripheral Interface) subsystem. The flaw arises from improper handling of a mutex lock related to SPI controller registration and unregistration. Specifically, a commit (6098475d4cb4) introduced a per-controller mutex (add_lock) to prevent deadlocks when adding SPI controllers on SPI buses. However, the mutex_unlock() call occurs after the SPI controller has already been freed via put_device(), leading to a use-after-free condition. The sequence is as follows: spi_unregister_controller() calls put_device() on the controller's device, which triggers spi_controller_release(), freeing the controller, and only then is mutex_unlock() called on the add_lock mutex. This ordering is incorrect because it attempts to unlock a mutex associated with a freed object, causing undefined behavior and potential kernel memory corruption. The fix involves moving the put_device() call to occur after the mutex_unlock(), ensuring the mutex is released before the controller is freed. This vulnerability affects specific Linux kernel versions identified by their commit hashes and was published on April 10, 2024. There are no known exploits in the wild at this time, and no CVSS score has been assigned. The vulnerability is technical and low-level, impacting kernel stability and security, particularly in systems using SPI controllers, which are common in embedded and IoT devices running Linux.
Potential Impact
For European organizations, the impact of CVE-2021-47195 depends largely on the deployment of Linux-based systems that utilize SPI controllers. Many industrial control systems, embedded devices, and IoT infrastructure in sectors such as manufacturing, automotive, telecommunications, and critical infrastructure rely on Linux kernels with SPI support. Exploitation of this vulnerability could lead to kernel crashes, denial of service, or potentially privilege escalation if an attacker can trigger the use-after-free condition. This could disrupt operational technology environments or embedded systems critical to European industries. Although no active exploits are known, the vulnerability poses a risk to system integrity and availability, especially in environments where SPI devices are dynamically added or removed. The risk is heightened in scenarios where untrusted users or processes have the ability to interact with SPI devices or load/unload SPI controllers. Confidentiality impact is limited unless combined with other vulnerabilities, but integrity and availability impacts are significant due to potential kernel crashes or memory corruption.
Mitigation Recommendations
European organizations should prioritize updating their Linux kernels to versions where this vulnerability is patched, ensuring the fix that reorders the mutex_unlock() and put_device() calls is applied. For embedded and IoT devices, firmware updates incorporating the patched kernel should be deployed promptly. Organizations should audit their use of SPI controllers and restrict access to SPI device management interfaces to trusted users and processes only. Employing kernel hardening techniques such as Kernel Address Space Layout Randomization (KASLR), Kernel Page Table Isolation (KPTI), and enabling kernel lockdown modes can reduce exploitation risk. Monitoring kernel logs for unusual SPI controller registration/unregistration activity may help detect exploitation attempts. In environments where immediate patching is not feasible, isolating affected systems and limiting user privileges can mitigate risk. Vendors and integrators should verify that their Linux distributions include the fix and communicate updates to customers. Finally, organizations should maintain robust backup and recovery procedures to minimize operational impact in case of exploitation.
Affected Countries
Germany, France, United Kingdom, Netherlands, Italy, Spain, Sweden, Finland, Poland, Belgium
CVE-2021-47195: Vulnerability in Linux Linux
Description
In the Linux kernel, the following vulnerability has been resolved: spi: fix use-after-free of the add_lock mutex Commit 6098475d4cb4 ("spi: Fix deadlock when adding SPI controllers on SPI buses") introduced a per-controller mutex. But mutex_unlock() of said lock is called after the controller is already freed: spi_unregister_controller(ctlr) -> put_device(&ctlr->dev) -> spi_controller_release(dev) -> mutex_unlock(&ctrl->add_lock) Move the put_device() after the mutex_unlock().
AI-Powered Analysis
Technical Analysis
CVE-2021-47195 is a use-after-free vulnerability in the Linux kernel's SPI (Serial Peripheral Interface) subsystem. The flaw arises from improper handling of a mutex lock related to SPI controller registration and unregistration. Specifically, a commit (6098475d4cb4) introduced a per-controller mutex (add_lock) to prevent deadlocks when adding SPI controllers on SPI buses. However, the mutex_unlock() call occurs after the SPI controller has already been freed via put_device(), leading to a use-after-free condition. The sequence is as follows: spi_unregister_controller() calls put_device() on the controller's device, which triggers spi_controller_release(), freeing the controller, and only then is mutex_unlock() called on the add_lock mutex. This ordering is incorrect because it attempts to unlock a mutex associated with a freed object, causing undefined behavior and potential kernel memory corruption. The fix involves moving the put_device() call to occur after the mutex_unlock(), ensuring the mutex is released before the controller is freed. This vulnerability affects specific Linux kernel versions identified by their commit hashes and was published on April 10, 2024. There are no known exploits in the wild at this time, and no CVSS score has been assigned. The vulnerability is technical and low-level, impacting kernel stability and security, particularly in systems using SPI controllers, which are common in embedded and IoT devices running Linux.
Potential Impact
For European organizations, the impact of CVE-2021-47195 depends largely on the deployment of Linux-based systems that utilize SPI controllers. Many industrial control systems, embedded devices, and IoT infrastructure in sectors such as manufacturing, automotive, telecommunications, and critical infrastructure rely on Linux kernels with SPI support. Exploitation of this vulnerability could lead to kernel crashes, denial of service, or potentially privilege escalation if an attacker can trigger the use-after-free condition. This could disrupt operational technology environments or embedded systems critical to European industries. Although no active exploits are known, the vulnerability poses a risk to system integrity and availability, especially in environments where SPI devices are dynamically added or removed. The risk is heightened in scenarios where untrusted users or processes have the ability to interact with SPI devices or load/unload SPI controllers. Confidentiality impact is limited unless combined with other vulnerabilities, but integrity and availability impacts are significant due to potential kernel crashes or memory corruption.
Mitigation Recommendations
European organizations should prioritize updating their Linux kernels to versions where this vulnerability is patched, ensuring the fix that reorders the mutex_unlock() and put_device() calls is applied. For embedded and IoT devices, firmware updates incorporating the patched kernel should be deployed promptly. Organizations should audit their use of SPI controllers and restrict access to SPI device management interfaces to trusted users and processes only. Employing kernel hardening techniques such as Kernel Address Space Layout Randomization (KASLR), Kernel Page Table Isolation (KPTI), and enabling kernel lockdown modes can reduce exploitation risk. Monitoring kernel logs for unusual SPI controller registration/unregistration activity may help detect exploitation attempts. In environments where immediate patching is not feasible, isolating affected systems and limiting user privileges can mitigate risk. Vendors and integrators should verify that their Linux distributions include the fix and communicate updates to customers. Finally, organizations should maintain robust backup and recovery procedures to minimize operational impact in case of exploitation.
For access to advanced analysis and higher rate limits, contact root@offseq.com
Technical Details
- Data Version
- 5.1
- Assigner Short Name
- Linux
- Date Reserved
- 2024-03-25T09:12:14.114Z
- Cisa Enriched
- true
- Cvss Version
- null
- State
- PUBLISHED
Threat ID: 682d9822c4522896dcbde090
Added to database: 5/21/2025, 9:08:50 AM
Last enriched: 6/28/2025, 4:56:49 AM
Last updated: 8/16/2025, 2:31:20 PM
Views: 14
Related Threats
CVE-2025-53948: CWE-415 Double Free in Santesoft Sante PACS Server
HighCVE-2025-52584: CWE-122 Heap-based Buffer Overflow in Ashlar-Vellum Cobalt
HighCVE-2025-46269: CWE-122 Heap-based Buffer Overflow in Ashlar-Vellum Cobalt
HighCVE-2025-54862: CWE-79 Improper Neutralization of Input During Web Page Generation (XSS or 'Cross-site Scripting') in Santesoft Sante PACS Server
MediumCVE-2025-54759: CWE-79 Improper Neutralization of Input During Web Page Generation (XSS or 'Cross-site Scripting') in Santesoft Sante PACS Server
MediumActions
Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.
External Links
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.