Skip to content

Commit

Permalink
vfio: powerpc/spapr: Disable DMA mappings on disabled container
Browse files Browse the repository at this point in the history
At the moment DMA map/unmap requests are handled irrespective to
the container's state. This allows the user space to pin memory which
it might not be allowed to pin.

This adds checks to MAP/UNMAP that the container is enabled, otherwise
-EPERM is returned.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
[aw: for the vfio related changes]
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
  • Loading branch information
Alexey Kardashevskiy authored and Michael Ellerman committed Jun 11, 2015
1 parent 2d270df commit 3c56e82
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/vfio/vfio_iommu_spapr_tce.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ static long tce_iommu_ioctl(void *iommu_data,
struct iommu_table *tbl = container->tbl;
unsigned long tce;

if (!container->enabled)
return -EPERM;

if (!tbl)
return -ENXIO;

Expand Down Expand Up @@ -362,6 +365,9 @@ static long tce_iommu_ioctl(void *iommu_data,
struct vfio_iommu_type1_dma_unmap param;
struct iommu_table *tbl = container->tbl;

if (!container->enabled)
return -EPERM;

if (WARN_ON(!tbl))
return -ENXIO;

Expand Down

0 comments on commit 3c56e82

Please sign in to comment.