vfio: avoid possible overflow in vfio_iommu_type1_pin_pages
authorYan Zhao <yan.y.zhao@intel.com>
Wed, 8 Apr 2020 07:12:34 +0000 (03:12 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 May 2020 06:15:14 +0000 (08:15 +0200)
commit 0ea971f8dcd6dee78a9a30ea70227cf305f11ff7 upstream.

add parentheses to avoid possible vaddr overflow.

Fixes: a54eb55045ae ("vfio iommu type1: Add support for mediated devices")
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/vfio/vfio_iommu_type1.c

index d864277..f471600 100644 (file)
@@ -593,7 +593,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)