KVM: Ensure local memslot copies operate on up-to-date arch-specific data
authorSean Christopherson <seanjc@google.com>
Thu, 4 Nov 2021 00:25:02 +0000 (00:25 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Dec 2021 08:04:43 +0000 (09:04 +0100)
commitcbe4fcf37150a409ab1bfc59be0cb3408ab22236
tree3d8c21371de1907ca362a22c9a3b281294ebbe21
parent2bdc79ac9a4f1447eb14c6edcd6b05787b93b221
KVM: Ensure local memslot copies operate on up-to-date arch-specific data

commit bda44d844758c70c8dc1478e6fc9c25efa90c5a7 upstream.

When modifying memslots, snapshot the "old" memslot and copy it to the
"new" memslot's arch data after (re)acquiring slots_arch_lock.  x86 can
change a memslot's arch data while memslot updates are in-progress so
long as it holds slots_arch_lock, thus snapshotting a memslot without
holding the lock can result in the consumption of stale data.

Fixes: b10a038e84d1 ("KVM: mmu: Add slots_arch_lock for memslot arch fields")
Cc: stable@vger.kernel.org
Cc: Ben Gardon <bgardon@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20211104002531.1176691-2-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
virt/kvm/kvm_main.c