Vulnerability · Published Feb 26, 2025 · Assigned by Linux

CVE-2021-47639KVM: x86/mmu: Zap _all_ roots when unmapping gfn range in TDP MMU

High 7.8

In plain English

A high-severity use-after-free in Linux from Linux. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 0.3% (higher than 17% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.

Severity (CVSS 3.1)7.8High
Exploit odds (30 days)0.3%top 83.2% of all CVEs
Exploited in the wildNo reportsCISA SSVC: none
Attack toolingNoneno public tooling known

Official 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>

Affected packages & fixed versions

EcosystemPackageFixed inAdvisory
Debian:12linux5.17.3-1DEBIAN-CVE-2021-47639
Debian:13linux5.17.3-1DEBIAN-CVE-2021-47639
Debian:14linux5.17.3-1DEBIAN-CVE-2021-47639
Ubuntu:22.04:LTSlinux5.15.0-37.39UBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-allwinner-5.19no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-aws5.15.0-1011.14UBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-aws-5.19no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-aws-6.2no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-aws-6.5no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-azure5.15.0-1010.12UBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-azure-5.19no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-azure-6.2no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-azure-6.5no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-azure-fde-5.19no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-azure-fde-6.2no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-gcp5.15.0-1008.12UBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-gcp-5.19no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-gcp-6.2no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-gcp-6.5no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-gke5.15.0-1008.10UBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-hwe-5.19no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-hwe-6.2no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-hwe-6.5no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-ibm5.15.0-1007.8UBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-intel-iot-realtimeno fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-intel-iotg5.15.0-1008.11UBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-kvm5.15.0-1010.11UBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-lowlatency5.15.0-37.39UBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-lowlatency-hwe-5.19no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.2no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.5no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-nvidia-6.2no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-nvidia-6.5no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-oem-5.17no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-oem-6.0no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-oem-6.1no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-oem-6.5no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-oracle5.15.0-1009.12UBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-oracle-6.5no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-raspi5.15.0-1011.13UBUNTU-CVE-2021-47639
Ubuntu:24.04:LTSlinux-raspi-realtimeno fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-realtimeno fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-riscvno fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-riscv-5.19no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-riscv-6.5no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-starfive-5.19no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-starfive-6.2no fix listedUBUNTU-CVE-2021-47639
Ubuntu:22.04:LTSlinux-starfive-6.5no fix listedUBUNTU-CVE-2021-47639

Affected products (as reported)

VendorProductVersions
Linux Linux b7cccd397f310739fb85383033e95580f99927e0 – before af47248407c0c5ae52a752af1ab5ce5b0db91502b7cccd397f310739fb85383033e95580f99927e0 – before 0c8a8da182d4333d9bbb9131d765145568c847b2b7cccd397f310739fb85383033e95580f99927e0 – before 8cf6f98ab1d16d5e607635a0c21c4231eb15367eb7cccd397f310739fb85383033e95580f99927e0 – before d62007edf01f5c11f75d0f4b1e538fc52a5b1982
Linux Linux 5.13

Weakness: CWE-416 · Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

References