# CVE-2021-47639: KVM: x86/mmu: Zap \_all\_ roots when unmapping gfn range in TDP MMU

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** HIGH 7.8
- **CVSS:** 7.8 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.25% (percentile 18, 2026-12-03)
- **CWE:** CWE-416
- **Published:** 2025-02-26T01:54:11.651Z
- **Modified:** 2026-08-05T08:48:44.903Z

## Who should check

- Anyone running Linux \>= b7cccd397f310739fb85383033e95580f99927e0, \< af47248407c0c5ae52a752af1ab5ce5b0db91502; \>= b7cccd397f310739fb85383033e95580f99927e0, \< 0c8a8da182d4333d9bbb9131d765145568c847b2; \>= b7cccd397f310739fb85383033e95580f99927e0, \< 8cf6f98ab1d16d5e607635a0c21c4231eb15367e; \>= b7cccd397f310739fb85383033e95580f99927e0, \< d62007edf01f5c11f75d0f4b1e538fc52a5b1982
- Anyone running Linux 5.13

## 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 and fixed versions

- Linux: \>= b7cccd397f310739fb85383033e95580f99927e0, \< af47248407c0c5ae52a752af1ab5ce5b0db91502; \>= b7cccd397f310739fb85383033e95580f99927e0, \< 0c8a8da182d4333d9bbb9131d765145568c847b2; \>= b7cccd397f310739fb85383033e95580f99927e0, \< 8cf6f98ab1d16d5e607635a0c21c4231eb15367e; \>= b7cccd397f310739fb85383033e95580f99927e0, \< d62007edf01f5c11f75d0f4b1e538fc52a5b1982 (cvelist)
- Linux: 5.13 (cvelist)

## Mitigation

- No fix listed yet: follow the vendor advisory.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2021-47639. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2021-47639.md
Affected: Linux >= b7cccd397f310739fb85383033e95580f99927e0, < af47248407c0c5ae52a752af1ab5ce5b0db91502; >= b7cccd397f310739fb85383033e95580f99927e0, < 0c8a8da182d4333d9bbb9131d765145568c847b2; >= b7cccd397f310739fb85383033e95580f99927e0, < 8cf6f98ab1d16d5e607635a0c21c4231eb15367e; >= b7cccd397f310739fb85383…
Fixed in: Linux 0c8a8da182d4333d9bbb9131d765145568c847b2, Linux 8cf6f98ab1d16d5e607635a0c21c4231eb15367e

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2021-47639 being exploited?

There is no confirmed exploitation: CVE-2021-47639 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.25% chance of exploitation in the next 30 days (as of 2026-12-03).

### How serious is CVE-2021-47639?

High: CVSS 7.8 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2021-47639?

Linux \>= b7cccd397f310739fb85383033e95580f99927e0, \< af47248407c0c5ae52a752af1ab5ce5b0db91502; \>= b7cccd397f310739fb85383033e95580f99927e0, \< 0c8a8da182d4333d9bbb9131d765145568c847b2; \>= b7cccd397f310739fb85383033e95580f99927e0, \< 8cf6f98ab1d16d5e607635a0c21c4231eb15367e; \>= b7cccd397f310739fb85383033e95580f99927e0, \< d62007edf01f5c11f75d0f4b1e538fc52a5b1982; Linux 5.13.

### Is there a fix for CVE-2021-47639?

Yes. Fixed in Linux 0c8a8da182d4333d9bbb9131d765145568c847b2, Linux 8cf6f98ab1d16d5e607635a0c21c4231eb15367e. No fix listed yet: follow the vendor advisory.

### How do I check if I'm affected by CVE-2021-47639?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/af47248407c0c5ae52a752af1ab5ce5b0db91502>
- patch: <https://git.kernel.org/stable/c/0c8a8da182d4333d9bbb9131d765145568c847b2>
- patch: <https://git.kernel.org/stable/c/8cf6f98ab1d16d5e607635a0c21c4231eb15367e>
- patch: <https://git.kernel.org/stable/c/d62007edf01f5c11f75d0f4b1e538fc52a5b1982>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2021-47639>

HTML: <https://flawdb.com/CVE-2021-47639> · JSON: <https://flawdb.com/api/v1/entries/CVE-2021-47639>
