kvmarm.lists.cs.columbia.edu archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: Release mmap_lock when using VM_SHARED with MTE
@ 2021-10-05 12:20 Quentin Perret
  2021-10-05 12:23 ` Marc Zyngier
  0 siblings, 1 reply; 2+ messages in thread
From: Quentin Perret @ 2021-10-05 12:20 UTC (permalink / raw)
  To: Marc Zyngier, James Morse, Alexandru Elisei, Suzuki K Poulose,
	Catalin Marinas, Will Deacon, Steven Price, linux-arm-kernel,
	kvmarm, linux-kernel
  Cc: kernel-team

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: ea7fc1bb1cd1 ("KVM: arm64: Introduce MTE VM feature")
Signed-off-by: Quentin Perret <qperret@google.com>
---
 arch/arm64/kvm/mmu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
index 1a94a7ca48f2..69bd1732a299 100644
--- a/arch/arm64/kvm/mmu.c
+++ b/arch/arm64/kvm/mmu.c
@@ -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 */
-- 
2.33.0.800.g4c38ced690-goog

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: arm64: Release mmap_lock when using VM_SHARED with MTE
  2021-10-05 12:20 [PATCH] KVM: arm64: Release mmap_lock when using VM_SHARED with MTE Quentin Perret
@ 2021-10-05 12:23 ` Marc Zyngier
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Zyngier @ 2021-10-05 12:23 UTC (permalink / raw)
  To: Alexandru Elisei, Quentin Perret, Will Deacon, Catalin Marinas,
	linux-kernel, James Morse, kvmarm, linux-arm-kernel,
	Steven Price, Suzuki K Poulose
  Cc: kernel-team

On Tue, 5 Oct 2021 13:20:31 +0100, Quentin Perret wrote:
> 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.

Applied to fixes, thanks!

[1/1] KVM: arm64: Release mmap_lock when using VM_SHARED with MTE
      commit: 6e6a8ef088e1222cb1250942f51ad9c1ab219ab2

Cheers,

	M.
-- 
Without deviation from the norm, progress is not possible.


_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-05 12:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05 12:20 [PATCH] KVM: arm64: Release mmap_lock when using VM_SHARED with MTE Quentin Perret
2021-10-05 12:23 ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).