FROMLIST: mm: write lock mmu_notifier_lock when registering mmu notifiers

Change mm_take_all_locks to also take the mmu_notifier_lock.
Note that mm_take_all_locks is called from mmu_notifier_register() only.

Signed-off-by: Michel Lespinasse <michel@lespinasse.org>
Link: https://lore.kernel.org/all/20220128131006.67712-25-michel@lespinasse.org/
Bug: 161210518
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I7ad82c6bc66f8f59a718dc4bf030674d9306a53d
This commit is contained in:
Michel Lespinasse
2022-01-24 17:43:55 -08:00
committed by Todd Kjos
parent 1ae855f191
commit 3e15787d22

View File

@@ -3594,6 +3594,10 @@ int mm_take_all_locks(struct mm_struct *mm)
mutex_lock(&mm_all_locks_mutex);
#if defined(CONFIG_MMU_NOTIFIER) && defined(CONFIG_SPECULATIVE_PAGE_FAULT)
percpu_down_write(mm->mmu_notifier_lock);
#endif
for (vma = mm->mmap; vma; vma = vma->vm_next) {
if (signal_pending(current))
goto out_unlock;
@@ -3681,6 +3685,10 @@ void mm_drop_all_locks(struct mm_struct *mm)
vm_unlock_mapping(vma->vm_file->f_mapping);
}
#if defined(CONFIG_MMU_NOTIFIER) && defined(CONFIG_SPECULATIVE_PAGE_FAULT)
percpu_up_write(mm->mmu_notifier_lock);
#endif
mutex_unlock(&mm_all_locks_mutex);
}