Skip to content

Commit 90f6e15

Browse files
author
Marc Zyngier
committed
arm/arm64: KVM: Take mmap_sem in stage2_unmap_vm
We don't hold the mmap_sem while searching for the VMAs when we try to unmap each memslot for a VM. Fix this properly to avoid unexpected results. Fixes: commit 957db10 ("arm/arm64: KVM: Introduce stage2_unmap_vm") Cc: [email protected] # v3.19+ Reviewed-by: Christoffer Dall <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent 955a3fc commit 90f6e15

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

arch/arm/kvm/mmu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,13 +803,15 @@ void stage2_unmap_vm(struct kvm *kvm)
803803
int idx;
804804

805805
idx = srcu_read_lock(&kvm->srcu);
806+
down_read(&current->mm->mmap_sem);
806807
spin_lock(&kvm->mmu_lock);
807808

808809
slots = kvm_memslots(kvm);
809810
kvm_for_each_memslot(memslot, slots)
810811
stage2_unmap_memslot(kvm, memslot);
811812

812813
spin_unlock(&kvm->mmu_lock);
814+
up_read(&current->mm->mmap_sem);
813815
srcu_read_unlock(&kvm->srcu, idx);
814816
}
815817

0 commit comments

Comments
 (0)