Skip to content

Commit 690e2ab

Browse files
committed
Merge tag 'vfio-v5.7-rc4' of git://github.com/awilliam/linux-vfio
Pull VFIO fixes from Alex Williamson: - copy_*_user validity check for new vfio_dma_rw interface (Yan Zhao) - Fix a potential math overflow (Yan Zhao) - Use follow_pfn() for calculating PFNMAPs (Sean Christopherson) * tag 'vfio-v5.7-rc4' of git://github.com/awilliam/linux-vfio: vfio/type1: Fix VA->PA translation for PFNMAP VMAs in vaddr_get_pfn() vfio: avoid possible overflow in vfio_iommu_type1_pin_pages vfio: checking of validity of user vaddr in vfio_dma_rw
2 parents 42eb62d + 5cbf326 commit 690e2ab

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/vfio/vfio_iommu_type1.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr,
342342
vma = find_vma_intersection(mm, vaddr, vaddr + 1);
343343

344344
if (vma && vma->vm_flags & VM_PFNMAP) {
345-
*pfn = ((vaddr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
346-
if (is_invalid_reserved_pfn(*pfn))
345+
if (!follow_pfn(vma, vaddr, pfn) &&
346+
is_invalid_reserved_pfn(*pfn))
347347
ret = 0;
348348
}
349349
done:
@@ -555,7 +555,7 @@ static int vfio_iommu_type1_pin_pages(void *iommu_data,
555555
continue;
556556
}
557557

558-
remote_vaddr = dma->vaddr + iova - dma->iova;
558+
remote_vaddr = dma->vaddr + (iova - dma->iova);
559559
ret = vfio_pin_page_external(dma, remote_vaddr, &phys_pfn[i],
560560
do_accounting);
561561
if (ret)
@@ -2345,10 +2345,10 @@ static int vfio_iommu_type1_dma_rw_chunk(struct vfio_iommu *iommu,
23452345
vaddr = dma->vaddr + offset;
23462346

23472347
if (write)
2348-
*copied = __copy_to_user((void __user *)vaddr, data,
2348+
*copied = copy_to_user((void __user *)vaddr, data,
23492349
count) ? 0 : count;
23502350
else
2351-
*copied = __copy_from_user(data, (void __user *)vaddr,
2351+
*copied = copy_from_user(data, (void __user *)vaddr,
23522352
count) ? 0 : count;
23532353
if (kthread)
23542354
unuse_mm(mm);

0 commit comments

Comments
 (0)