提交 719aee2c 编写于 作者: A Alex Williamson 提交者: Greg Kroah-Hartman

vfio/type1: Fix unmap overflow off-by-one

commit 58fec830fc19208354895d9832785505046d6c01 upstream.

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: 71a7d3d7 ("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: NPei Zhang <pezhang@redhat.com>
Debugged-by: NPeter Xu <peterx@redhat.com>
Reviewed-by: NDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: NPeter Xu <peterx@redhat.com>
Tested-by: NPeter Xu <peterx@redhat.com>
Reviewed-by: NCornelia Huck <cohuck@redhat.com>
Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 1e235ec0
...@@ -878,7 +878,7 @@ static int vfio_dma_do_unmap(struct vfio_iommu *iommu, ...@@ -878,7 +878,7 @@ static int vfio_dma_do_unmap(struct vfio_iommu *iommu,
return -EINVAL; return -EINVAL;
if (!unmap->size || unmap->size & mask) if (!unmap->size || unmap->size & mask)
return -EINVAL; return -EINVAL;
if (unmap->iova + unmap->size < unmap->iova || if (unmap->iova + unmap->size - 1 < unmap->iova ||
unmap->size > SIZE_MAX) unmap->size > SIZE_MAX)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册