KVM: x86/mmu: Harden new PGD against roots without shadow pages
authorSean Christopherson <seanjc@google.com>
Sat, 29 Jul 2023 00:51:57 +0000 (17:51 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 31 Aug 2023 18:08:21 +0000 (14:08 -0400)
commitc30e000e690af74f61a161fa60be140f23948cb1
tree06cf1bf450e99c3f268163b7cc48cc1d83a2641f
parentc5f2d5645f9b7c12c9546ced9ec1f1a558870747
KVM: x86/mmu: Harden new PGD against roots without shadow pages

Harden kvm_mmu_new_pgd() against NULL pointer dereference bugs by sanity
checking that the target root has an associated shadow page prior to
dereferencing said shadow page.  The code in question is guaranteed to
only see roots with shadow pages as fast_pgd_switch() explicitly frees the
current root if it doesn't have a shadow page, i.e. is a PAE root, and
that in turn prevents valid roots from being cached, but that's all very
subtle.

Link: https://lore.kernel.org/r/20230729005200.1057358-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/mmu.c