KVM: SVM: load control fields from VMCB12 before checking them
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 31 Mar 2021 10:24:43 +0000 (06:24 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 7 Apr 2021 13:00:09 +0000 (15:00 +0200)
commit5f6625f5cd5c593fae05a6ce22b406166bc796b8
tree87d70dc3336cc246c5eb9446c8d24b64c567d6a3
parent6aaa3c2ebb4fefe06ce79b70b4b8ca43ff460ab4
KVM: SVM: load control fields from VMCB12 before checking them

commit a58d9166a756a0f4a6618e4f593232593d6df134 upstream.

Avoid races between check and use of the nested VMCB controls.  This
for example ensures that the VMRUN intercept is always reflected to the
nested hypervisor, instead of being processed by the host.  Without this
patch, it is possible to end up with svm->nested.hsave pointing to
the MSR permission bitmap for nested guests.

This bug is CVE-2021-29657.

Reported-by: Felix Wilhelm <fwilhelm@google.com>
Cc: stable@vger.kernel.org
Fixes: 2fcf4876ada ("KVM: nSVM: implement on demand allocation of the nested state")
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/svm/nested.c