Skip to contentSkip to conversation

Patch "arm/arm64: KVM: Take mmap_sem in stage2_unmap_vm" has been added to the 4.9-stable tree

PATCH [email protected] 1 participant 1 message Apr 9, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

arm/arm64: KVM: Take mmap_sem in stage2_unmap_vm

to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
arm-arm64-kvm-take-mmap_sem-in-stage2_unmap_vm.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 90f6e150e44a0dc3883110eeb3ab35d1be42b6bb Mon Sep 17 00:00:00 2001

From: Marc Zyngier <[email protected]>
Date: Thu, 16 Mar 2017 18:20:49 +0000
Subject: arm/arm64: KVM: Take mmap_sem in stage2_unmap_vm

From: Marc Zyngier <[email protected]>

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 957db105c997 ("arm/arm64: KVM: Introduce stage2_unmap_vm")
---
 arch/arm/kvm/mmu.c |    2 ++
 1 file changed, 2 insertions(+)
arch/arm/kvm/mmu.c +2 -0
@@ -803,6 +803,7 @@ void stage2_unmap_vm(struct kvm *kvm)
 	int idx;
 
 	idx = srcu_read_lock(&kvm->srcu);
+	down_read(&current->mm->mmap_sem);
 	spin_lock(&kvm->mmu_lock);
 
 	slots = kvm_memslots(kvm);
@@ -810,6 +811,7 @@ void stage2_unmap_vm(struct kvm *kvm)
 		stage2_unmap_memslot(kvm, memslot);
 
 	spin_unlock(&kvm->mmu_lock);
+	up_read(&current->mm->mmap_sem);
 	srcu_read_unlock(&kvm->srcu, idx);
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.9/kvm-arm-arm64-fix-locking-for-kvm_free_stage2_pgd.patch queue-4.9/arm-arm64-kvm-take-mmap_sem-in-kvm_arch_prepare_memory_region.patch queue-4.9/arm-arm64-kvm-take-mmap_sem-in-stage2_unmap_vm.patch