Commit 205323b8 authored by Yan Zhao's avatar Yan Zhao Committed by Alex Williamson

vfio: checking of validity of user vaddr in vfio_dma_rw

instead of calling __copy_to/from_user(), use copy_to_from_user() to
ensure vaddr range is a valid user address range before accessing them.

Fixes: 8d46c0cc ("vfio: introduce vfio_dma_rw to read/write a range of IOVAs")
Signed-off-by: default avatarYan Zhao <yan.y.zhao@intel.com>
Reported-by: default avatarKees Cook <keescook@chromium.org>
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent ae83d0b4
...@@ -2345,10 +2345,10 @@ static int vfio_iommu_type1_dma_rw_chunk(struct vfio_iommu *iommu, ...@@ -2345,10 +2345,10 @@ static int vfio_iommu_type1_dma_rw_chunk(struct vfio_iommu *iommu,
vaddr = dma->vaddr + offset; vaddr = dma->vaddr + offset;
if (write) if (write)
*copied = __copy_to_user((void __user *)vaddr, data, *copied = copy_to_user((void __user *)vaddr, data,
count) ? 0 : count; count) ? 0 : count;
else else
*copied = __copy_from_user(data, (void __user *)vaddr, *copied = copy_from_user(data, (void __user *)vaddr,
count) ? 0 : count; count) ? 0 : count;
if (kthread) if (kthread)
unuse_mm(mm); unuse_mm(mm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment