# CVE-2021-47094: KVM: x86/mmu: Don't advance iterator after restart due to yielding

> 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.22% (percentile 7, 2026-11-28)
- **Published:** 2024-03-04T18:10:45.240Z
- **Modified:** 2026-08-05T08:45:57.100Z

## Who should check

- Anyone running Linux \>= faaf05b00aecdb347ffd1d763d024394ec0329f8, \< d884eefd75cc54887bc2e9e724207443525dfb2c; \>= faaf05b00aecdb347ffd1d763d024394ec0329f8, \< 3a0f64de479cae75effb630a2e0a237ca0d0623c
- Anyone running Linux 5.10

## Description

In the Linux kernel, the following vulnerability has been resolved:

KVM: x86/mmu: Don't advance iterator after restart due to yielding

After dropping mmu\_lock in the TDP MMU, restart the iterator during
tdp\_iter\_next() and do not advance the iterator.  Advancing the iterator
results in skipping the top-level SPTE and all its children, which is
fatal if any of the skipped SPTEs were not visited before yielding.

When zapping all SPTEs, i.e. when min\_level == root\_level, restarting the
iter and then invoking tdp\_iter\_next() is always fatal if the current gfn
has as a valid SPTE, as advancing the iterator results in try\_step\_side()
skipping the current gfn, which wasn't visited before yielding.

Sprinkle WARNs on iter-\>yielded being true in various helpers that are
often used in conjunction with yielding, and tag the helper with
\_\_must\_check to reduce the probabily of improper usage.

Failing to zap a top-level SPTE manifests in one of two ways.  If a valid
SPTE is skipped by both kvm\_tdp\_mmu\_zap\_all() and kvm\_tdp\_mmu\_put\_root(),
the shadow page will be leaked and KVM will WARN accordingly.

  WARNING: CPU: 1 PID: 3509 at arch/x86/kvm/mmu/tdp\_mmu.c:46 \[kvm\]
  RIP: 0010:kvm\_mmu\_uninit\_tdp\_mmu+0x3e/0x50 \[kvm\]
  Call Trace:
   \<TASK\>
   kvm\_arch\_destroy\_vm+0x130/0x1b0 \[kvm\]
   kvm\_destroy\_vm+0x162/0x2a0 \[kvm\]
   kvm\_vcpu\_release+0x34/0x60 \[kvm\]
   \_\_fput+0x82/0x240
   task\_work\_run+0x5c/0x90
   do\_exit+0x364/0xa10
   ? futex\_unqueue+0x38/0x60
   do\_group\_exit+0x33/0xa0
   get\_signal+0x155/0x850
   arch\_do\_signal\_or\_restart+0xed/0x750
   exit\_to\_user\_mode\_prepare+0xc5/0x120
   syscall\_exit\_to\_user\_mode+0x1d/0x40
   do\_syscall\_64+0x48/0xc0
   entry\_SYSCALL\_64\_after\_hwframe+0x44/0xae

If kvm\_tdp\_mmu\_zap\_all() skips a gfn/SPTE but that SPTE is then zapped by
kvm\_tdp\_mmu\_put\_root(), KVM triggers a use-after-free in the form of
marking a struct page as dirty/accessed after it has been put back on the
free list.  This directly triggers a WARN due to encountering a page with
page\_count() == 0, but it can also lead to data corruption and additional
errors in the kernel.

  WARNING: CPU: 7 PID: 1995658 at arch/x86/kvm/../../../virt/kvm/kvm\_main.c:171
  RIP: 0010:kvm\_is\_zone\_device\_pfn.part.0+0x9e/0xd0 \[kvm\]
  Call Trace:
   \<TASK\>
   kvm\_set\_pfn\_dirty+0x120/0x1d0 \[kvm\]
   \_\_handle\_changed\_spte+0x92e/0xca0 \[kvm\]
   \_\_handle\_changed\_spte+0x63c/0xca0 \[kvm\]
   \_\_handle\_changed\_spte+0x63c/0xca0 \[kvm\]
   \_\_handle\_changed\_spte+0x63c/0xca0 \[kvm\]
   zap\_gfn\_range+0x549/0x620 \[kvm\]
   kvm\_tdp\_mmu\_put\_root+0x1b6/0x270 \[kvm\]
   mmu\_free\_root\_page+0x219/0x2c0 \[kvm\]
   kvm\_mmu\_free\_roots+0x1b4/0x4e0 \[kvm\]
   kvm\_mmu\_unload+0x1c/0xa0 \[kvm\]
   kvm\_arch\_destroy\_vm+0x1f2/0x5c0 \[kvm\]
   kvm\_put\_kvm+0x3b1/0x8b0 \[kvm\]
   kvm\_vcpu\_release+0x4e/0x70 \[kvm\]
   \_\_fput+0x1f7/0x8c0
   task\_work\_run+0xf8/0x1a0
   do\_exit+0x97b/0x2230
   do\_group\_exit+0xda/0x2a0
   get\_signal+0x3be/0x1e50
   arch\_do\_signal\_or\_restart+0x244/0x17f0
   exit\_to\_user\_mode\_prepare+0xcb/0x120
   syscall\_exit\_to\_user\_mode+0x1d/0x40
   do\_syscall\_64+0x4d/0x90
   entry\_SYSCALL\_64\_after\_hwframe+0x44/0xae

Note, the underlying bug existed even before commit 1af4a96025b3 ("KVM:
x86/mmu: Yield in TDU MMU iter even if no SPTES changed") moved calls to
tdp\_mmu\_iter\_cond\_resched() to the beginning of loops, as KVM could still
incorrectly advance past a top-level entry when yielding on a lower-level
entry.  But with respect to leaking shadow pages, the bug was introduced
by yielding before processing the current gfn.

Alternatively, tdp\_mmu\_iter\_cond\_resched() could simply fall through, or
callers could jump to their "retry" label.  The downside of that approach
is that tdp\_mmu\_iter\_cond\_resched() \_must\_ be called before anything else
in the loop, and there's no easy way to enfornce that requirement.

Ideally, KVM would handling the cond\_resched() fully within the iterator
macro (the code is actually quite clean) and avoid this entire class of
bugs, but that is extremely difficult do wh
---truncated---

## Affected and fixed versions

- Linux: \>= faaf05b00aecdb347ffd1d763d024394ec0329f8, \< d884eefd75cc54887bc2e9e724207443525dfb2c; \>= faaf05b00aecdb347ffd1d763d024394ec0329f8, \< 3a0f64de479cae75effb630a2e0a237ca0d0623c (cvelist)
- Linux: 5.10 (cvelist)

## Mitigation

- Upgrade Linux to 3a0f64de479cae75effb630a2e0a237ca0d0623c or later.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2021-47094.md
Affected: Linux >= faaf05b00aecdb347ffd1d763d024394ec0329f8, < d884eefd75cc54887bc2e9e724207443525dfb2c; >= faaf05b00aecdb347ffd1d763d024394ec0329f8, < 3a0f64de479cae75effb630a2e0a237ca0d0623c; Linux 5.10
Fixed in: Linux 3a0f64de479cae75effb630a2e0a237ca0d0623c

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-47094 being exploited?

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

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

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

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

Linux \>= faaf05b00aecdb347ffd1d763d024394ec0329f8, \< d884eefd75cc54887bc2e9e724207443525dfb2c; \>= faaf05b00aecdb347ffd1d763d024394ec0329f8, \< 3a0f64de479cae75effb630a2e0a237ca0d0623c; Linux 5.10.

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

Yes. Fixed in Linux 3a0f64de479cae75effb630a2e0a237ca0d0623c. Upgrade Linux to 3a0f64de479cae75effb630a2e0a237ca0d0623c or later.

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

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/d884eefd75cc54887bc2e9e724207443525dfb2c>
- patch: <https://git.kernel.org/stable/c/3a0f64de479cae75effb630a2e0a237ca0d0623c>

## 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-47094>

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