Re: [PATCH] vfio/type1: check pfn valid before converting to struct page

Jason Gunthorpe
2023-05-16T11:51:07Z

On Tue, May 16, 2023 at 05:30:07PM +0800, Yan Zhao wrote:
> vfio_pin_page_external() can return a phys_pfn for vma with VM_PFNMAP,
> e.g. for MMIO PFNs.
>
> It's necessary to check if it's a valid pfn before calling pfn_to_page().
>
> Fixes: 34a255e67615 ("vfio: Replace phys_pfn with pages for vfio_pin_pages()")
> Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
> ---
> drivers/vfio/vfio_iommu_type1.c | 5 +++++
> 1 file changed, 5 insertions(+)

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason