]> Git Repo - linux.git/commitdiff
mm/hmm: return error for non-vma snapshots
authorJason Gunthorpe <[email protected]>
Fri, 27 Mar 2020 20:00:21 +0000 (17:00 -0300)
committerJason Gunthorpe <[email protected]>
Mon, 30 Mar 2020 19:58:36 +0000 (16:58 -0300)
The pagewalker does not call most ops with NULL vma, those are all routed
to hmm_vma_walk_hole() via ops->pte_hole instead.

Thus hmm_vma_fault() is only called with a NULL vma from
hmm_vma_walk_hole(), so hoist the NULL vma check to there.

Now it is clear that snapshotting with no vma is a HMM_PFN_ERROR as
without a vma we have no path to call hmm_vma_fault().

Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
mm/hmm.c

index 9b6a8a26a1fa6af18020a782dfa7a293f07b253b..280585833adfc1b35eddd11c0ee28d15b0ef60ad 100644 (file)
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -83,9 +83,6 @@ static int hmm_vma_fault(unsigned long addr, unsigned long end,
        WARN_ON_ONCE(!required_fault);
        hmm_vma_walk->last = addr;
 
-       if (!vma)
-               return -EFAULT;
-
        if (required_fault & HMM_NEED_WRITE_FAULT) {
                if (!(vma->vm_flags & VM_WRITE))
                        return -EPERM;
@@ -170,6 +167,11 @@ static int hmm_vma_walk_hole(unsigned long addr, unsigned long end,
        npages = (end - addr) >> PAGE_SHIFT;
        pfns = &range->pfns[i];
        required_fault = hmm_range_need_fault(hmm_vma_walk, pfns, npages, 0);
+       if (!walk->vma) {
+               if (required_fault)
+                       return -EFAULT;
+               return hmm_pfns_fill(addr, end, range, HMM_PFN_ERROR);
+       }
        if (required_fault)
                return hmm_vma_fault(addr, end, required_fault, walk);
        hmm_vma_walk->last = addr;
This page took 0.05958 seconds and 4 git commands to generate.