summaryrefslogtreecommitdiff
path: root/mm/memory.c
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <willy@infradead.org>2023-03-27 18:45:15 +0100
committerAndrew Morton <akpm@linux-foundation.org>2023-04-05 19:43:00 -0700
commit58ef47ef7db9dfc2730dc039498cc76130ea3c3d (patch)
treed54aff16b7b756de9cac97a3eadcda5579fe9d4a /mm/memory.c
parent0050d7f5ee532f92e8ab1efcec6547bfac527973 (diff)
mm: hold the RCU read lock over calls to ->map_pages
Prevent filesystems from doing things which sleep in their map_pages method. This is in preparation for a pagefault path protected only by RCU. Link: https://lkml.kernel.org/r/20230327174515.1811532-4-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Darrick J. Wong <djwong@kernel.org> Cc: Dave Chinner <david@fromorbit.com> Cc: David Howells <dhowells@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/memory.c')
-rw-r--r--mm/memory.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/mm/memory.c b/mm/memory.c
index 7716f2cc4b68..ec7e89cc0532 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4450,6 +4450,7 @@ static vm_fault_t do_fault_around(struct vm_fault *vmf)
/* The page offset of vmf->address within the VMA. */
pgoff_t vma_off = vmf->pgoff - vmf->vma->vm_pgoff;
pgoff_t from_pte, to_pte;
+ vm_fault_t ret;
/* The PTE offset of the start address, clamped to the VMA. */
from_pte = max(ALIGN_DOWN(pte_off, nr_pages),
@@ -4465,9 +4466,13 @@ static vm_fault_t do_fault_around(struct vm_fault *vmf)
return VM_FAULT_OOM;
}
- return vmf->vma->vm_ops->map_pages(vmf,
- vmf->pgoff + from_pte - pte_off,
- vmf->pgoff + to_pte - pte_off);
+ rcu_read_lock();
+ ret = vmf->vma->vm_ops->map_pages(vmf,
+ vmf->pgoff + from_pte - pte_off,
+ vmf->pgoff + to_pte - pte_off);
+ rcu_read_unlock();
+
+ return ret;
}
/* Return true if we should do read fault-around, false otherwise */