CVE-2021-47639·Kernel vulnerability
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>
- Severity
- high
- Software
- Kernel
- Fixed in
- 5.17.2
- Published
- 2025-02-26
Affected versions
From: 5.17
Until: 5.17.2
Fixed in: 5.17.2
How to fix this CVE
Update your Linux kernel to version 5.17.2 or later to resolve this use-after-free vulnerability in the KVM TDP MMU. The vulnerability allows kernel memory corruption when the MMU notifier runs concurrently with invalid root page table zapping. Apply the kernel update immediately and reboot your system to activate the patched version.
sudo dnf update kernel kernel-develDefensia detects this vulnerability
How to check if you are affected
- Run 'uname -r' to check your current kernel version. If it shows 5.17.0, 5.17.1, or 5.17.2 (before the fix), your system is vulnerable.
- Verify if KVM/virtualization is enabled by checking 'lsmod | grep kvm' — if output is empty, the vulnerable KVM code path is not loaded.
- Search system logs for use-after-free or zone device pfn warnings: 'grep -i "use-after-free\|kvm_is_zone_device_pfn" /var/log/kern.log /var/log/messages'
- Confirm the patch is applied by running 'uname -r' after reboot and verifying the kernel version is 5.17.2 or later.
FAQ
What is CVE-2021-47639?
This is a use-after-free vulnerability in the Linux kernel's KVM (Kernel Virtual Machine) TDP MMU module. When the MMU notifier invalidates guest memory mappings, the code fails to zap both valid and invalid root page tables, leading to kernel memory corruption and potential system crash or privilege escalation.
Is CVE-2021-47639 being actively exploited?
No, this vulnerability is not listed in the CISA KEV (Known Exploited Vulnerabilities) catalog and no public exploits are currently available. However, it requires local access and KVM to be enabled, limiting widespread impact.
What versions of Kernel are affected by CVE-2021-47639?
Linux kernel versions 5.17 through 5.17.2 are vulnerable. The fix is included in kernel 5.17.2 and all later versions.
How do I check if my server is vulnerable to CVE-2021-47639?
Run 'uname -r' and check if the output shows kernel 5.17.0, 5.17.1, or 5.17.2. If your kernel version is 5.17.2 or higher, or if 'lsmod | grep kvm' returns no results, you are not vulnerable.
Does Defensia detect CVE-2021-47639?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If the Linux kernel is installed on a monitored server, CVE-2021-47639 will appear in your dashboard with remediation steps.
Related Kernel CVEs
References
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2021-47639. Free for 1 server.
Get started free