lkml.org 
[lkml]   [2018]   [Apr]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] vfio iommu type1: no need to check task->mm if task has been destroyed
Date
The task structure in vfio_dma struct used to identify the same
task who map it or other task who shares same adress space is
allowed to unmap. But if the task who map it has exited, mm of
the task has been set to null, we should unmap the vfio dma directly.

Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
---
Hi all,
When I unplug a vcpu from a VM lanched with a VFIO hostdev device,
I found that the *vfio_dma* mapped by this vcpu task could not be unmaped
in the future, so I send this patch to unmap vfio_dma directly if the
task who mapped it has exited.

Howerver this patch may introduce a new security risk because any task can
unmap the *vfio_dma* if the mapper task has exited.

---
drivers/vfio/vfio_iommu_type1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 5c212bf..601a353 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -947,7 +947,7 @@ static int vfio_dma_do_unmap(struct vfio_iommu *iommu,
* Task with same address space who mapped this iova range is
* allowed to unmap the iova range.
*/
- if (dma->task->mm != current->mm)
+ if (dma->task->mm && (dma->task->mm != current->mm))
break;

if (!RB_EMPTY_ROOT(&dma->pfn_list)) {
--
1.8.3.1

\
 
 \ /
  Last update: 2018-04-18 12:58    [W:0.135 / U:0.440 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site