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

From: Yan Zhao
Date: Thu May 18 2023 - 21:51:19 EST


On Thu, May 18, 2023 at 11:07:09AM -0700, Sean Christopherson wrote:
> On Thu, May 18, 2023, Yan Zhao wrote:
> > On Wed, May 17, 2023 at 08:19:04AM -0700, Sean Christopherson wrote:
> > > On Tue, May 16, 2023, 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()")
> > >
> > > Might be worth adding a blurb to call out that this is _not_ ABI breakage. Prior
> > Do you mean "_not_ ABI breakage" with
> > 34a255e67615 ("vfio: Replace phys_pfn with pages for vfio_pin_pages()")
> > or with this fix commit?
>
> Mostly the former. I brought it up because _if_ there was breakage in that commit,
> then this fix would be "wrong" in the sense that it wouldn't undo any breakage, and
> would likely make it harder to restore the previous behavior.

Ok. Let me post v2 to describe the problem and background clearly.

Thanks!