• Alex Williamson's avatar
    vfio/type1: Fix task tracking for QEMU vCPU hotplug · 827faa4e
    Alex Williamson authored
    [ Upstream commit 48d8476b ]
    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: 's avatarXu Yandong <xuyandong2@huawei.com>
    Signed-off-by: 's avatarAlex Williamson <alex.williamson@redhat.com>
    Signed-off-by: 's avatarSasha Levin <alexander.levin@microsoft.com>
    Signed-off-by: 's avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Last commit
Last update
mdev Loading commit data...
pci Loading commit data...
platform Loading commit data...
Kconfig Loading commit data...
Makefile Loading commit data...
vfio.c Loading commit data...
vfio_iommu_spapr_tce.c Loading commit data...
vfio_iommu_type1.c Loading commit data...
vfio_spapr_eeh.c Loading commit data...
virqfd.c Loading commit data...