Skip to content

Commit 8e88806

Browse files
Marc Zyngiergregkh
authored andcommitted
arm/arm64: KVM: Take mmap_sem in stage2_unmap_vm
commit 90f6e150e44a0dc3883110eeb3ab35d1be42b6bb upstream. 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") Reviewed-by: Christoffer Dall <cdall@linaro.org> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 193b590 commit 8e88806

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

arch/arm/kvm/mmu.c

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

798798
idx = srcu_read_lock(&kvm->srcu);
799+
down_read(&current->mm->mmap_sem);
799800
spin_lock(&kvm->mmu_lock);
800801

801802
slots = kvm_memslots(kvm);
802803
kvm_for_each_memslot(memslot, slots)
803804
stage2_unmap_memslot(kvm, memslot);
804805

805806
spin_unlock(&kvm->mmu_lock);
807+
up_read(&current->mm->mmap_sem);
806808
srcu_read_unlock(&kvm->srcu, idx);
807809
}
808810

0 commit comments

Comments
 (0)