aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@redhat.com>2019-01-08 00:13:22 -0500
committerAlex Williamson <alex.williamson@redhat.com>2019-01-08 11:31:28 -0500
commit58fec830fc19208354895d9832785505046d6c01 (patch)
treea67fd59017fdf486f854b627c1128675660d9b4d
parentd1fc1176c055c9ec9c6ec4d113a284e0bad9d09a (diff)
vfio/type1: Fix unmap overflow off-by-one
The below referenced commit adds a test for integer overflow, but in doing so prevents the unmap ioctl from ever including the last page of the address space. Subtract one to compare to the last address of the unmap to avoid the overflow and wrap-around. Fixes: 71a7d3d78e3c ("vfio/type1: silence integer overflow warning") Link: https://bugzilla.redhat.com/show_bug.cgi?id=1662291 Cc: stable@vger.kernel.org # v4.15+ Reported-by: Pei Zhang <pezhang@redhat.com> Debugged-by: Peter Xu <peterx@redhat.com> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Peter Xu <peterx@redhat.com> Tested-by: Peter Xu <peterx@redhat.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
-rw-r--r--drivers/vfio/vfio_iommu_type1.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 7651cfb14836..73652e21efec 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -878,7 +878,7 @@ static int vfio_dma_do_unmap(struct vfio_iommu *iommu,
878 return -EINVAL; 878 return -EINVAL;
879 if (!unmap->size || unmap->size & mask) 879 if (!unmap->size || unmap->size & mask)
880 return -EINVAL; 880 return -EINVAL;
881 if (unmap->iova + unmap->size < unmap->iova || 881 if (unmap->iova + unmap->size - 1 < unmap->iova ||
882 unmap->size > SIZE_MAX) 882 unmap->size > SIZE_MAX)
883 return -EINVAL; 883 return -EINVAL;
884 884