]> git.baikalelectronics.ru Git - kernel.git/commit
vfio/type1: Empty batch for pfnmap pages
authorDaniel Jordan <daniel.m.jordan@oracle.com>
Thu, 25 Mar 2021 01:05:52 +0000 (21:05 -0400)
committerAlex Williamson <alex.williamson@redhat.com>
Thu, 25 Mar 2021 18:48:38 +0000 (12:48 -0600)
commitca03d8cae75074c91798e96d8fc2fd42d4f77d15
treec970b68f92ec70b92e4e882fe2ebfb11ad0a0399
parenta123a92a85a64b2b0aa97706608092508241de7b
vfio/type1: Empty batch for pfnmap pages

When vfio_pin_pages_remote() returns with a partial batch consisting of
a single VM_PFNMAP pfn, a subsequent call will unfortunately try
restoring it from batch->pages, resulting in vfio mapping the wrong page
and unbalancing the page refcount.

Prevent the function from returning with this kind of partial batch to
avoid the issue.  There's no explicit check for a VM_PFNMAP pfn because
it's awkward to do so, so infer it from characteristics of the batch
instead.  This may result in occasional false positives but keeps the
code simpler.

Fixes: c61aae5539e6 ("vfio/type1: Batch page pinning")
Link: https://lkml.kernel.org/r/20210323133254.33ed9161@omen.home.shazbot.org/
Reported-by: Alex Williamson <alex.williamson@redhat.com>
Suggested-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com>
Message-Id: <20210325010552.185481-1-daniel.m.jordan@oracle.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/vfio_iommu_type1.c