CVE-2021-47639: KVM: x86/mmu: Zap _all_ roots when unmapping gfn range in TDP MMU
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>
Security readout for executives and security teams
Plain-English summary
This is a Linux kernel KVM virtualization flaw. On affected x86 hosts, KVM can keep references to memory after it should have been unmapped, creating a use-after-free condition. The CVSS rating is high, but the source bundle does not show known active exploitation.
Executive priority
Treat this as a high-priority virtualization host patching item. Business urgency depends on whether affected Linux KVM hosts are present and reachable by local users or workloads. No active exploitation is evidenced in the supplied sources.
Technical view
CVE-2021-47639 is a CWE-416 use-after-free in Linux KVM x86 TDP MMU handling. During gfn range unmapping, invalid roots were not always zapped in mmu_notifier paths, allowing KVM work to continue after notifier return against freed page state.
Likely exposure
Exposure is most relevant to Linux systems running KVM on x86 kernels in the affected ranges cited by the CVE data, especially virtualization hosts. The source bundle does not provide distro package mappings, cloud-provider status, or appliance-specific affected lists.
Exploitation context
The CVSS vector indicates local attack surface, low privileges, no user interaction, and potential high confidentiality, integrity, and availability impact. The CVE is not marked KEV, and the provided sources do not cite active exploitation or public exploit availability.
Researcher notes
Root cause is incomplete zapping of invalid TDP MMU roots during unmap and mmu_notifier handling. The source notes possible fatal behavior when delayed zapping later triggers operations such as kvm_set_pfn_dirty after notifier completion.
Mitigation direction
Update affected Linux kernels using vendor or distro guidance.
Confirm fixes include the referenced stable KVM TDP MMU commits.
Prioritize x86 KVM virtualization hosts before general Linux endpoints.
Review vendor advisories for supported backports and package names.
If patch timing is constrained, reduce local access to affected hosts.
Validation and detection
Inventory Linux kernel versions on KVM-capable x86 hosts.
Check whether running kernels fall within the affected CVE ranges.
Verify distro changelogs reference CVE-2021-47639 or the stable commits.
Confirm the patched kernel is booted after maintenance.
Record no KEV listing unless future sources change that status.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · low confidence lookup
CWE-416: Exact CWE lookup
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
1CVSS vectors
3Timeline events
1ADP providers
5Source links
SSVC decision data
CISA-ADPCISA Coordinator
Timestamp
Version
2.0.3
Exploitation: noneAutomatable: noTechnical Impact: total
CVSS vector scores
1 official score
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.