Commit f7a421d
committed
KVM: x86: Fix shadow paging use-after-free due to unexpected role
jira VULN-191426
cve CVE-2026-53359
commit-author Paolo Bonzini <pbonzini@redhat.com>
commit 81ccda3
upstream-diff |
Upstream adds the check to kvm_mmu_get_child_sp(), which doesn't
exist here, so it goes into kvm_mmu_child_sp_exists() at the reuse
sites in __direct_map() and FNAME(fetch). The expected role comes
from kvm_mmu_child_role(), split out of kvm_mmu_get_page() (as
upstream did in 2e65e84) so the check and the allocator can't
derive different roles.
Commit 0cb2af2 ("KVM: x86: Fix shadow paging use-after-free due
to unexpected GFN") fixed a shadow paging mismatch between stored and
computed GFNs; the bug could be triggered by changing a PDE mapping from
outside the guest, and then deleting a memslot. The rmap_remove()
call would miss entries created after the PDE change because the GFN
of the leaf SPTE does not match the GFN of the struct kvm_mmu_page.
A similar hole however remains if the modified PDE points to a non-leaf
page. In this case the gfn can be made to match, but the role does not
match: the original large 2MB page creates a kvm_mmu_page with direct=1,
while the new 4KB needs a kvm_mmu_page with direct=0. However,
kvm_mmu_get_child_sp() does not compare the role, and therefore reuses
the page.
The next step is installing a leaf (4KB) SPTE on the new path which
records an rmap entry under the gfn resolved by the walk. But when
that child is zapped its parent kvm_mmu_page has direct=1 and
kvm_mmu_page_get_gfn() computes the gfn for the 4KB page as
sp->gfn + index instead of using sp->shadowed_translation[] (or sp->gfns[]
in older kernels). It therefore fails to remove the recorded entry.
When the memslot is dropped the shadow page is freed but the rmap
entry survives, as in the scenario that was already fixed. Code that
later walks that gfn (dirty logging, MMU notifier invalidation, and
so on) dereferences an sptep that lies in the freed page, causing the
use-after-free.
Fixes: 2032a93 ("KVM: MMU: Don't allocate gfns page for direct mmu pages")
Reported-by: Hyunwoo Kim <imv4bel@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 81ccda3)
Signed-off-by: Sultan Alsawaf <sultan@ciq.com>1 parent 6e68f66 commit f7a421d
2 files changed
Lines changed: 39 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2053 | 2053 | | |
2054 | 2054 | | |
2055 | 2055 | | |
2056 | | - | |
2057 | | - | |
2058 | | - | |
2059 | | - | |
2060 | | - | |
2061 | | - | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
2062 | 2059 | | |
2063 | 2060 | | |
2064 | 2061 | | |
2065 | | - | |
2066 | 2062 | | |
2067 | | - | |
2068 | | - | |
2069 | | - | |
2070 | 2063 | | |
2071 | 2064 | | |
2072 | 2065 | | |
| |||
2080 | 2073 | | |
2081 | 2074 | | |
2082 | 2075 | | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
2083 | 2095 | | |
2084 | 2096 | | |
2085 | 2097 | | |
| |||
2289 | 2301 | | |
2290 | 2302 | | |
2291 | 2303 | | |
2292 | | - | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
2293 | 2307 | | |
| 2308 | + | |
2294 | 2309 | | |
2295 | 2310 | | |
2296 | 2311 | | |
2297 | 2312 | | |
2298 | 2313 | | |
2299 | 2314 | | |
2300 | | - | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
2301 | 2320 | | |
2302 | 2321 | | |
2303 | 2322 | | |
| |||
3001 | 3020 | | |
3002 | 3021 | | |
3003 | 3022 | | |
3004 | | - | |
| 3023 | + | |
| 3024 | + | |
3005 | 3025 | | |
3006 | 3026 | | |
3007 | 3027 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
661 | 661 | | |
662 | 662 | | |
663 | 663 | | |
| 664 | + | |
664 | 665 | | |
665 | | - | |
| 666 | + | |
| 667 | + | |
666 | 668 | | |
667 | | - | |
668 | 669 | | |
669 | 670 | | |
670 | 671 | | |
| |||
721 | 722 | | |
722 | 723 | | |
723 | 724 | | |
724 | | - | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
725 | 728 | | |
726 | 729 | | |
727 | 730 | | |
| |||
0 commit comments