KVM: arm64: Fix read-side race on updates to vcpu reset state
authorOliver Upton <oupton@google.com>
Wed, 18 Aug 2021 20:21:30 +0000 (20:21 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Sep 2021 10:28:03 +0000 (12:28 +0200)
commit53921242cf995a6c9867154696ba9f07b6bd7957
tree4c3cb2874c362c24331ab2682a16cecd5666ada9
parentb9b89da56af761fbb12da26ca5eb0c068446ec16
KVM: arm64: Fix read-side race on updates to vcpu reset state

[ Upstream commit 6654f9dfcb88fea3b9affc180dc3c04333d0f306 ]

KVM correctly serializes writes to a vCPU's reset state, however since
we do not take the KVM lock on the read side it is entirely possible to
read state from two different reset requests.

Cure the race for now by taking the KVM lock when reading the
reset_state structure.

Fixes: 358b28f09f0a ("arm/arm64: KVM: Allow a VCPU to fully reset itself")
Signed-off-by: Oliver Upton <oupton@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210818202133.1106786-2-oupton@google.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/arm64/kvm/reset.c