1
0
Fork 0
remarkable-linux/drivers/vfio
Alex Williamson 827faa4eb5 vfio/type1: Fix task tracking for QEMU vCPU hotplug
[ Upstream commit 48d8476b41 ]

MAP_DMA ioctls might be called from various threads within a process,
for example when using QEMU, the vCPU threads are often generating
these calls and we therefore take a reference to that vCPU task.
However, QEMU also supports vCPU hotplug on some machines and the task
that called MAP_DMA may have exited by the time UNMAP_DMA is called,
resulting in the mm_struct pointer being NULL and thus a failure to
match against the existing mapping.

To resolve this, we instead take a reference to the thread
group_leader, which has the same mm_struct and resource limits, but
is less likely exit, at least in the QEMU case.  A difficulty here is
guaranteeing that the capabilities of the group_leader match that of
the calling thread, which we resolve by tracking CAP_IPC_LOCK at the
time of calling rather than at an indeterminate time in the future.
Potentially this also results in better efficiency as this is now
recorded once per MAP_DMA ioctl.

Reported-by: Xu Yandong <xuyandong2@huawei.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-08-03 07:50:23 +02:00
..
mdev vfio/mdev: Check globally for duplicate devices 2018-08-03 07:50:22 +02:00
pci vfio/pci: Fix potential Spectre v1 2018-07-25 11:25:08 +02:00
platform vfio: platform: Fix reset module leak in error path 2018-08-03 07:50:22 +02:00
Kconfig vfio: Fix build break when SPAPR_TCE_IOMMU=n 2017-02-08 13:13:25 -07:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
vfio.c vfio: Stall vfio_del_group_dev() for container group detach 2017-08-30 14:02:16 -06:00
vfio_iommu_spapr_tce.c KVM: PPC: Check if IOMMU page is contained in the pinned physical page 2018-07-28 07:55:41 +02:00
vfio_iommu_type1.c vfio/type1: Fix task tracking for QEMU vCPU hotplug 2018-08-03 07:50:23 +02:00
vfio_spapr_eeh.c drivers/vfio: Support EEH error injection 2015-05-12 20:33:35 +10:00
virqfd.c sched/wait: Rename wait_queue_t => wait_queue_entry_t 2017-06-20 12:18:27 +02:00