]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: Fix race when enabling KVM_ARM_CAP_MTE
authorSteven Price <steven.price@arm.com>
Thu, 29 Jul 2021 16:00:36 +0000 (17:00 +0100)
committerMarc Zyngier <maz@kernel.org>
Thu, 29 Jul 2021 16:34:01 +0000 (17:34 +0100)
commit5a2e413d977aae14fe3b2b0fe87e98be5b6fd2d2
treea192daad41b4e977b196a9ee9cf06cb8b357f067
parentfefcebd062b17af4dfa448468dad8f306c34bbd5
KVM: arm64: Fix race when enabling KVM_ARM_CAP_MTE

When enabling KVM_CAP_ARM_MTE the ioctl checks that there are no VCPUs
created to ensure that the capability is enabled before the VM is
running. However no locks are held at that point so it is
(theoretically) possible for another thread in the VMM to create VCPUs
between the check and actually setting mte_enabled. Close the race by
taking kvm->lock.

Reported-by: Alexandru Elisei <alexandru.elisei@arm.com>
Fixes: 49430d4d3574 ("KVM: arm64: Expose KVM_ARM_CAP_MTE")
Signed-off-by: Steven Price <steven.price@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210729160036.20433-1-steven.price@arm.com
arch/arm64/kvm/arm.c