mm-mmap-prevent-pagefault-handler-from-racing-with-mmu_notifier-registration.patch removed from -mm tree
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 <[email protected]>
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.
---
mm/mmap.c | 9 +++++++++ 1 file changed, 9 insertions(+)
mm/mmap.c renamed from mm/mmap.c~mm-mmap-prevent-pagefault-handler-from-racing-with-mmu_notifier-registration +9 -0
@@ -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_structif (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 [email protected] are