[PATCH 5/7] xen/privcmd: Use verify_page_range()

From: Peter Zijlstra
Date: Mon Apr 12 2021 - 04:09:15 EST


Avoid using apply_to_page_range() from modules, use the safer
verify_page_range() instead.

Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
drivers/xen/privcmd.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/xen/privcmd.c
+++ b/drivers/xen/privcmd.c
@@ -946,9 +946,9 @@ static int privcmd_mmap(struct file *fil
* on a per pfn/pte basis. Mapping calls that fail with ENOENT
* can be then retried until success.
*/
-static int is_mapped_fn(pte_t *pte, unsigned long addr, void *data)
+static int is_mapped_fn(pte_t pte, unsigned long addr, void *data)
{
- return pte_none(*pte) ? 0 : -EBUSY;
+ return pte_none(pte) ? 0 : -EBUSY;
}

static int privcmd_vma_range_is_mapped(
@@ -956,8 +956,8 @@ static int privcmd_vma_range_is_mapped(
unsigned long addr,
unsigned long nr_pages)
{
- return apply_to_page_range(vma->vm_mm, addr, nr_pages << PAGE_SHIFT,
- is_mapped_fn, NULL) != 0;
+ return verify_page_range(vma->vm_mm, addr, nr_pages << PAGE_SHIFT,
+ is_mapped_fn, NULL) != 0;
}

const struct file_operations xen_privcmd_fops = {