]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: arm64: Release mmap_lock when using VM_SHARED with MTE
authorQuentin Perret <qperret@google.com>
Tue, 5 Oct 2021 12:20:31 +0000 (13:20 +0100)
committerMarc Zyngier <maz@kernel.org>
Tue, 5 Oct 2021 12:22:45 +0000 (13:22 +0100)
VM_SHARED mappings are currently forbidden in a memslot with MTE to
prevent two VMs racing to sanitise the same page. However, this check
is performed while holding current->mm's mmap_lock, but fails to release
it. Fix this by releasing the lock when needed.

Fixes: ef0072e156e4 ("KVM: arm64: Introduce MTE VM feature")
Signed-off-by: Quentin Perret <qperret@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211005122031.809857-1-qperret@google.com
arch/arm64/kvm/mmu.c

index 1a94a7ca48f27da2d739ad7b2e76eb403cad451b..69bd1732a299f79066c4d667c701e0288f5e2528 100644 (file)
@@ -1529,8 +1529,10 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
                 * when updating the PG_mte_tagged page flag, see
                 * sanitise_mte_tags for more details.
                 */
-               if (kvm_has_mte(kvm) && vma->vm_flags & VM_SHARED)
-                       return -EINVAL;
+               if (kvm_has_mte(kvm) && vma->vm_flags & VM_SHARED) {
+                       ret = -EINVAL;
+                       break;
+               }
 
                if (vma->vm_flags & VM_PFNMAP) {
                        /* IO region dirty page logging not allowed */