Skip to main content

CVE-2021-47227: Vulnerability in Linux Linux

Medium
VulnerabilityCVE-2021-47227cvecve-2021-47227
Published: Tue May 21 2024 (05/21/2024, 14:19:31 UTC)
Source: CVE
Vendor/Project: Linux
Product: Linux

Description

In the Linux kernel, the following vulnerability has been resolved: x86/fpu: Prevent state corruption in __fpu__restore_sig() The non-compacted slowpath uses __copy_from_user() and copies the entire user buffer into the kernel buffer, verbatim. This means that the kernel buffer may now contain entirely invalid state on which XRSTOR will #GP. validate_user_xstate_header() can detect some of that corruption, but that leaves the onus on callers to clear the buffer. Prior to XSAVES support, it was possible just to reinitialize the buffer, completely, but with supervisor states that is not longer possible as the buffer clearing code split got it backwards. Fixing that is possible but not corrupting the state in the first place is more robust. Avoid corruption of the kernel XSAVE buffer by using copy_user_to_xstate() which validates the XSAVE header contents before copying the actual states to the kernel. copy_user_to_xstate() was previously only called for compacted-format kernel buffers, but it works for both compacted and non-compacted forms. Using it for the non-compacted form is slower because of multiple __copy_from_user() operations, but that cost is less important than robust code in an already slow path. [ Changelog polished by Dave Hansen ]

AI-Powered Analysis

AILast updated: 06/26/2025, 14:51:51 UTC

Technical Analysis

CVE-2021-47227 is a vulnerability in the Linux kernel's x86 floating-point unit (FPU) state restoration code, specifically in the __fpu__restore_sig() function. The issue arises from how the kernel handles user-space buffers when restoring the FPU state using the XRSTOR instruction. In the non-compacted slowpath, the kernel uses __copy_from_user() to copy the entire user buffer verbatim into a kernel buffer without validating the contents first. This can result in the kernel buffer containing invalid or corrupted FPU state data, which causes the XRSTOR instruction to trigger a general protection fault (#GP). Although the function validate_user_xstate_header() can detect some corruption, it relies on callers to clear or sanitize the buffer, which was not consistently done. Prior to the introduction of XSAVES support, the kernel could simply reinitialize the buffer to avoid corruption. However, with supervisor states introduced by XSAVES, the buffer clearing logic was flawed, leading to potential state corruption. The fix involves replacing the direct __copy_from_user() call with copy_user_to_xstate(), which validates the XSAVE header before copying the actual FPU states. This function was previously only used for compacted-format buffers but now applies to both compacted and non-compacted forms. While this approach is slower due to multiple __copy_from_user() calls, it ensures robust handling of the FPU state and prevents kernel state corruption. This vulnerability affects Linux kernel versions identified by the commit hash b860eb8dce5906b14e3a7f3c771e0b3d6ef61b94 and was publicly disclosed on May 21, 2024. There are no known exploits in the wild at this time.

Potential Impact

For European organizations, this vulnerability poses a risk primarily to systems running affected Linux kernel versions on x86 architectures. The vulnerability could lead to kernel crashes or general protection faults when handling corrupted or maliciously crafted FPU state data from user space. This may result in denial of service (DoS) conditions, impacting availability of critical services and infrastructure. Although there is no indication that this vulnerability allows privilege escalation or arbitrary code execution, the kernel crashes could disrupt operations, especially in environments relying on high availability such as financial institutions, telecommunications, and cloud service providers. Additionally, systems that process untrusted user input or run multi-tenant workloads (e.g., virtualized environments or containers) may be more exposed. The lack of known exploits reduces immediate risk, but the vulnerability's presence in the kernel's core FPU handling code means that attackers with local access could potentially trigger system instability. Given the widespread use of Linux in European data centers, government agencies, and enterprises, unpatched systems could face operational disruptions.

Mitigation Recommendations

European organizations should prioritize updating their Linux kernels to versions that include the patch for CVE-2021-47227. Since the fix involves changes to kernel code handling XSAVE buffers, applying official kernel updates from trusted vendors or distributions is essential. Organizations should: 1) Identify all systems running affected Linux kernel versions, especially those on x86 architectures. 2) Deploy kernel updates promptly, ensuring that the patched kernel with the copy_user_to_xstate() fix is in place. 3) For environments where immediate patching is challenging, consider restricting untrusted user access to vulnerable systems to reduce the risk of exploitation. 4) Monitor system logs for kernel faults or crashes related to FPU state restoration, which may indicate attempted exploitation or triggering of the vulnerability. 5) In virtualized or containerized environments, ensure hypervisors and container runtimes are also updated and configured to limit exposure to malicious user-space inputs. 6) Engage with Linux distribution vendors for backported patches if using long-term support kernels. These steps go beyond generic advice by emphasizing identification of affected systems, prioritization of kernel updates, and monitoring for specific kernel fault indicators related to this vulnerability.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
Linux
Date Reserved
2024-04-10T18:59:19.529Z
Cisa Enriched
true
Cvss Version
null
State
PUBLISHED

Threat ID: 682d9835c4522896dcbea0f9

Added to database: 5/21/2025, 9:09:09 AM

Last enriched: 6/26/2025, 2:51:51 PM

Last updated: 8/8/2025, 2:27:38 PM

Views: 18

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats