FROMLIST: mm: Allow fault_dirty_shared_page() to be called under the VMA lock

By making maybe_unlock_mmap_for_io() handle the VMA lock correctly,
we make fault_dirty_shared_page() safe to be called without the mmap
lock held.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reported-by: David Hildenbrand <david@redhat.com>
Tested-by: Suren Baghdasaryan <surenb@google.com>

Link: https://lore.kernel.org/all/20230812002033.1002367-1-willy@infradead.org/

Bug: 293665307
Change-Id: Ifed050cc4d194c538765ab403de09199b94c7b1b
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
Matthew Wilcox (Oracle) 2023-08-12 01:20:33 +01:00 committed by Suren Baghdasaryan
parent 83ab986324
commit 9e066d4b35

View File

@ -619,7 +619,7 @@ static inline struct file *maybe_unlock_mmap_for_io(struct vm_fault *vmf,
if (fault_flag_allow_retry_first(flags) &&
!(flags & FAULT_FLAG_RETRY_NOWAIT)) {
fpin = get_file(vmf->vma->vm_file);
mmap_read_unlock(vmf->vma->vm_mm);
release_fault_lock(vmf);
}
return fpin;
}