Skip to main content

CVE-2021-47639: Vulnerability in Linux Linux

High
VulnerabilityCVE-2021-47639cvecve-2021-47639
Published: Wed Feb 26 2025 (02/26/2025, 01:54:11 UTC)
Source: CVE
Vendor/Project: Linux
Product: Linux

Description

In the Linux kernel, the following vulnerability has been resolved: KVM: x86/mmu: Zap _all_ roots when unmapping gfn range in TDP MMU Zap both valid and invalid roots when zapping/unmapping a gfn range, as KVM must ensure it holds no references to the freed page after returning from the unmap operation. Most notably, the TDP MMU doesn't zap invalid roots in mmu_notifier callbacks. This leads to use-after-free and other issues if the mmu_notifier runs to completion while an invalid root zapper yields as KVM fails to honor the requirement that there must be _no_ references to the page after the mmu_notifier returns. The bug is most easily reproduced by hacking KVM to cause a collision between set_nx_huge_pages() and kvm_mmu_notifier_release(), but the bug exists between kvm_mmu_notifier_invalidate_range_start() and memslot updates as well. Invalidating a root ensures pages aren't accessible by the guest, and KVM won't read or write page data itself, but KVM will trigger e.g. kvm_set_pfn_dirty() when zapping SPTEs, and thus completing a zap of an invalid root _after_ the mmu_notifier returns is fatal. WARNING: CPU: 24 PID: 1496 at arch/x86/kvm/../../../virt/kvm/kvm_main.c:173 [kvm] RIP: 0010:kvm_is_zone_device_pfn+0x96/0xa0 [kvm] Call Trace: <TASK> kvm_set_pfn_dirty+0xa8/0xe0 [kvm] __handle_changed_spte+0x2ab/0x5e0 [kvm] __handle_changed_spte+0x2ab/0x5e0 [kvm] __handle_changed_spte+0x2ab/0x5e0 [kvm] zap_gfn_range+0x1f3/0x310 [kvm] kvm_tdp_mmu_zap_invalidated_roots+0x50/0x90 [kvm] kvm_mmu_zap_all_fast+0x177/0x1a0 [kvm] set_nx_huge_pages+0xb4/0x190 [kvm] param_attr_store+0x70/0x100 module_attr_store+0x19/0x30 kernfs_fop_write_iter+0x119/0x1b0 new_sync_write+0x11c/0x1b0 vfs_write+0x1cc/0x270 ksys_write+0x5f/0xe0 do_syscall_64+0x38/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae </TASK>

AI-Powered Analysis

AILast updated: 07/03/2025, 05:27:50 UTC

Technical Analysis

CVE-2021-47639 is a high-severity vulnerability in the Linux kernel's Kernel-based Virtual Machine (KVM) subsystem, specifically affecting the x86 architecture's memory management unit (MMU) implementation. The flaw arises from improper handling of root page tables during the unmapping of guest frame number (GFN) ranges in the Two-Dimensional Paging (TDP) MMU. The vulnerability is due to KVM failing to zap (invalidate) all roots, including invalid roots, when unmapping GFNs. This leads to use-after-free conditions because references to freed pages may persist after the unmap operation completes, violating the requirement that no references to freed pages remain once the memory notifier callback returns. The issue is particularly evident in scenarios where there is a collision between set_nx_huge_pages() and kvm_mmu_notifier_release(), but also exists in interactions between kvm_mmu_notifier_invalidate_range_start() and memory slot updates. The improper zapping can cause KVM to access freed memory, triggering faults such as use-after-free, which can lead to arbitrary code execution, privilege escalation, or system crashes within the host kernel. The vulnerability affects Linux kernel versions identified by the commit hash b7cccd397f310739fb85383033e95580f99927e0 and likely other versions prior to the patch. The CVSS v3.1 score is 7.8 (high), reflecting local attack vector, low attack complexity, requiring privileges but no user interaction, and impacts confidentiality, integrity, and availability. No known exploits are reported in the wild yet. The vulnerability is categorized under CWE-416 (Use After Free). The technical root cause is a failure in the KVM MMU notifier logic to fully invalidate all page table roots, leading to unsafe memory references during guest memory unmapping operations.

Potential Impact

For European organizations, the impact of CVE-2021-47639 can be significant, especially those relying on Linux-based virtualization infrastructure using KVM for cloud services, private data centers, or edge computing. Exploitation could allow a local attacker with limited privileges (e.g., a guest VM user or a less privileged host user) to escalate privileges to the host kernel level, potentially compromising the entire host system and all hosted virtual machines. This can lead to unauthorized data access, data corruption, service disruption, or complete system takeover. Given the widespread use of Linux and KVM in European enterprises, government agencies, and cloud providers, the vulnerability poses a risk to confidentiality, integrity, and availability of critical systems. Additionally, the vulnerability could be leveraged in multi-tenant environments to break isolation between virtual machines, threatening sensitive data and compliance with European data protection regulations such as GDPR. The absence of known exploits in the wild provides a window for mitigation, but the high severity and kernel-level impact necessitate prompt action.

Mitigation Recommendations

1. Immediate application of the official Linux kernel patches that address this vulnerability is critical. Organizations should track their Linux distribution vendor advisories and deploy updated kernel versions that include the fix for CVE-2021-47639. 2. For environments where immediate patching is not feasible, consider restricting access to KVM virtualization hosts to trusted administrators and users only, minimizing the risk of local exploitation. 3. Employ strict access controls and monitoring on virtual machine management interfaces to detect suspicious activities that might indicate exploitation attempts. 4. Use kernel hardening features such as Kernel Page Table Isolation (KPTI), SELinux/AppArmor policies, and seccomp filters to reduce the attack surface. 5. Regularly audit and update virtualization infrastructure components, including hypervisors and guest OS configurations, to ensure they are not susceptible to chained exploits. 6. Implement robust logging and intrusion detection systems to identify anomalous kernel or KVM behavior indicative of exploitation attempts. 7. In cloud or multi-tenant environments, consider additional isolation mechanisms such as hardware-assisted virtualization extensions and dedicated host allocation to limit cross-VM attack vectors.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
Linux
Date Reserved
2025-02-26T01:48:21.519Z
Cisa Enriched
true
Cvss Version
3.1
State
PUBLISHED

Threat ID: 682d9834c4522896dcbe962d

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

Last enriched: 7/3/2025, 5:27:50 AM

Last updated: 8/11/2025, 5:37:43 PM

Views: 8

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