* [merged mm-stable] mm-mmap-prevent-pagefault-handler-from-racing-with-mmu_notifier-registration.patch removed from -mm tree
@ 2023-04-06 3:03 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2023-04-06 3:03 UTC (permalink / raw)
To: mm-commits, surenb, akpm
The quilt patch titled
Subject: mm/mmap: prevent pagefault handler from racing with mmu_notifier registration
has been removed from the -mm tree. Its filename was
mm-mmap-prevent-pagefault-handler-from-racing-with-mmu_notifier-registration.patch
This patch was dropped because it was merged into the mm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Suren Baghdasaryan <surenb@google.com>
Subject: mm/mmap: prevent pagefault handler from racing with mmu_notifier registration
Date: Mon, 27 Feb 2023 09:36:20 -0800
Page fault handlers might need to fire MMU notifications while a new
notifier is being registered. Modify mm_take_all_locks to write-lock all
VMAs and prevent this race with page fault handlers that would hold VMA
locks. VMAs are locked before i_mmap_rwsem and anon_vma to keep the same
locking order as in page fault handlers.
Link: https://lkml.kernel.org/r/20230227173632.3292573-22-surenb@google.com
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/mmap.c | 9 +++++++++
1 file changed, 9 insertions(+)
--- a/mm/mmap.c~mm-mmap-prevent-pagefault-handler-from-racing-with-mmu_notifier-registration
+++ a/mm/mmap.c
@@ -3494,6 +3494,7 @@ static void vm_lock_mapping(struct mm_st
* of mm/rmap.c:
* - all hugetlbfs_i_mmap_rwsem_key locks (aka mapping->i_mmap_rwsem for
* hugetlb mapping);
+ * - all vmas marked locked
* - all i_mmap_rwsem locks;
* - all anon_vma->rwseml
*
@@ -3519,6 +3520,13 @@ int mm_take_all_locks(struct mm_struct *
mas_for_each(&mas, vma, ULONG_MAX) {
if (signal_pending(current))
goto out_unlock;
+ vma_start_write(vma);
+ }
+
+ mas_set(&mas, 0);
+ mas_for_each(&mas, vma, ULONG_MAX) {
+ if (signal_pending(current))
+ goto out_unlock;
if (vma->vm_file && vma->vm_file->f_mapping &&
is_vm_hugetlb_page(vma))
vm_lock_mapping(mm, vma->vm_file->f_mapping);
@@ -3605,6 +3613,7 @@ void mm_drop_all_locks(struct mm_struct
if (vma->vm_file && vma->vm_file->f_mapping)
vm_unlock_mapping(vma->vm_file->f_mapping);
}
+ vma_end_write_all(mm);
mutex_unlock(&mm_all_locks_mutex);
}
_
Patches currently in -mm which might be from surenb@google.com are
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-06 3:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-06 3:03 [merged mm-stable] mm-mmap-prevent-pagefault-handler-from-racing-with-mmu_notifier-registration.patch removed from -mm tree Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.