Skip to content
  • Alex Williamson's avatar
    vfio: Remove unnecessary uses of vfio_container.group_lock · 7f56c30b
    Alex Williamson authored
    
    
    The original intent of vfio_container.group_lock is to protect
    vfio_container.group_list, however over time it's become a crutch to
    prevent changes in container composition any time we call into the
    iommu driver backend.  This introduces problems when we start to have
    more complex interactions, for example when a user's DMA unmap request
    triggers a notification to an mdev vendor driver, who responds by
    attempting to unpin mappings within that request, re-entering the
    iommu backend.  We incorrectly assume that the use of read-locks here
    allow for this nested locking behavior, but a poorly timed write-lock
    could in fact trigger a deadlock.
    
    The current use of group_lock seems to fall into the trap of locking
    code, not data.  Correct that by removing uses of group_lock that are
    not directly related to group_list.  Note that the vfio type1 iommu
    backend has its own mutex, vfio_iommu.lock, which it uses to protect
    itself for each of these interfaces anyway.  The group_lock appears to
    be a redundancy for these interfaces and type1 even goes so far as to
    release its mutex to allow for exactly the re-entrant code path above.
    
    Reported-by: default avatarChuanxiao Dong <chuanxiao.dong@intel.com>
    Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
    Acked-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
    Cc: stable@vger.kernel.org # v4.10+
    7f56c30b