CVE-2026-99472: KVM: pfncache: use a dedicated invalidation sequence for cache refresh
In the Linux kernel, the following vulnerability has been resolved:
KVM: pfncache: use a dedicated invalidation sequence for cache refresh
The gfntopfncache refresh path guards against mmu notifier invalidations which complete while it has dropped gpc->lock for the HVA->PFN lookup: hvatopfnretry() samples kvm->mmuinvalidateseq and retries if it changed, or if mnactiveinvalidatecount is still elevated.
That is insufficient for HVA-based caches. mmuinvalidateseq is only advanced by kvmmmuinvalidateend() when the invalidated range overlaps a memslot, and an HVA-based cache (e.g. the Xen sharedinfo page mapped with KVMXENATTRTYPESHAREDINFOHVA) need not be backed by any memslot at all. An invalidation of the cached HVA which starts and ends entirely within the lookup window is thus invisible to the retry check: mnactiveinvalidatecount is back to zero and the sequence never moved. The refresh then publishes a mapping of a page which has already been freed, and the next reader dereferences it:
BUG: KASAN: use-after-free in kvmxensharedinfoinit+0x3c6/0x440 Read of size 4 at addr ffff8880599c2900 by task syz.2.383/7257
Since gfntopfncacheinvalidatestart() deliberately skips caches which are not currently valid (including one whose refresh is in progress, as the refresh clears the valid flag before dropping the lock), the retry check is the only line of defence, and it must fire for any invalidation, not just those hitting a memslot.
Add a dedicated kvm->gpcinvalidateseq, incremented by every kvmmmunotifierinvalidaterangeend() under mninvalidatelock before mnactiveinvalidatecount is decremented, and check it in hvatopfnretry() instead of mmuinvalidateseq. Incrementing in rangeend() in the same critical section as the in-progress count also closes the variant where the cache is activated with the contested HVA only after invalidaterangestart() has run.
The same bug is also reachable through the per-vCPU vcpuinfo cache (KVMXENVCPUATTRTYPEVCPUINFOHVA), where the stale mapping is then dereferenced by kvmsetupguestpvclock() on the next KVMRUN:
BUG: KASAN: use-after-free in kvmsetupguestpvclock+0x5bf/0x660
This intentionally makes refresh retry on unrelated mmu notifier events; restoring precision (and reworking the GPC locking more generally) is left for a subsequent series.
Reproducers: https://david.woodhou.se/xenshinforace.c https://david.woodhou.se/vcpuinforace.c
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.2