Skip to content

Commit afe84f3

Browse files
committed
vfio/type1: Catch zero from pin_user_pages_remote()
pin_user_pages_remote() can currently return zero for invalid args or zero nr_pages, neither of which should ever happen. However vaddr_get_pfns() indicates it should only ever return a positive value or -errno and there's a theoretical case where this can slip through and be unhandled by callers. Therefore convert zero to -EFAULT. Reviewed-by: Peter Xu <[email protected]> Reviewed-by: Mitchell Augustin <[email protected]> Tested-by: Mitchell Augustin <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alex Williamson <[email protected]>
1 parent 4111216 commit afe84f3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/vfio/vfio_iommu_type1.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,8 @@ static int vaddr_get_pfns(struct mm_struct *mm, unsigned long vaddr,
564564
if (ret > 0) {
565565
*pfn = page_to_pfn(pages[0]);
566566
goto done;
567+
} else if (!ret) {
568+
ret = -EFAULT;
567569
}
568570

569571
vaddr = untagged_addr_remote(mm, vaddr);

0 commit comments

Comments
 (0)