]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: lock slots_lock around device assignment
authorAlex Williamson <alex.williamson@redhat.com>
Wed, 18 Apr 2012 03:46:44 +0000 (21:46 -0600)
committerPaul Gortmaker <paul.gortmaker@windriver.com>
Mon, 10 Feb 2014 21:10:43 +0000 (16:10 -0500)
commit624a0120be37b570a4f931933e48e3874fb9fdfb
tree997ec40d3e44d4445cb14e6827ee478627a13a2f
parent232fc56294ae61346b56a84d54417619fb187d41
KVM: lock slots_lock around device assignment

commit 21a1416a1c945c5aeaeaf791b63c64926018eb77 upstream.

As pointed out by Jason Baron, when assigning a device to a guest
we first set the iommu domain pointer, which enables mapping
and unmapping of memory slots to the iommu.  This leaves a window
where this path is enabled, but we haven't synchronized the iommu
mappings to the existing memory slots.  Thus a slot being removed
at that point could send us down unexpected code paths removing
non-existent pinnings and iommu mappings.  Take the slots_lock
around creating the iommu domain and initial mappings as well as
around iommu teardown to avoid this race.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
[PG: drop goto for EPERM check, 2.6.34 doesn't have that code]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
virt/kvm/iommu.c