Skip to contentSkip to conversation

vfio: avoid possible overflow in vfio_iommu_type1_pin_pages

PATCH New Yan Zhao 1 participant 1 message Apr 8, 2020

Subsystems (2)
lore
Share & tools
lore

Yan Zhao

author
#0 lore raw

PATCH 1/1 vfio: avoid possible overflow in vfio_iommu_type1_pin_pages

add parentheses to avoid possible vaddr overflow.

Fixes a54eb55045ae ("vfio iommu type1: Add support for mediated devices")
---
 drivers/vfio/vfio_iommu_type1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vfio/vfio_iommu_type1.c +1 -1
index 85b32c325282..3aefcc8e2933 100644
@@ -555,7 +555,7 @@ static int vfio_iommu_type1_pin_pages(void *iommu_data,
 			continue;
 		}
 
-		remote_vaddr = dma->vaddr + iova - dma->iova;
+		remote_vaddr = dma->vaddr + (iova - dma->iova);
 		ret = vfio_pin_page_external(dma, remote_vaddr, &phys_pfn[i],
 					     do_accounting);
 		if (ret)
Signature · 1 line
2.17.1