UPSTREAM: mm: handle write faults to RO pages under the VMA lock
I think this is a pretty rare occurrence, but for consistency handle faults with the VMA lock held the same way that we handle other faults with the VMA lock held. Link: https://lkml.kernel.org/r/20231006195318.4087158-7-willy@infradead.org Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Suren Baghdasaryan <surenb@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> (cherry picked from commit 4a68fef16df9d88d528094116f8bbd2dbfa62089) Bug: 293665307 Change-Id: I69cec218c8a1fe14df3268722e6b1be6dffe7978 Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
parent
c1da94fa44
commit
4a518d8633
13
mm/memory.c
13
mm/memory.c
@ -3358,10 +3358,9 @@ static vm_fault_t wp_pfn_shared(struct vm_fault *vmf)
|
||||
vm_fault_t ret;
|
||||
|
||||
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
||||
if (vmf->flags & FAULT_FLAG_VMA_LOCK) {
|
||||
vma_end_read(vmf->vma);
|
||||
return VM_FAULT_RETRY;
|
||||
}
|
||||
ret = vmf_can_call_fault(vmf);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
vmf->flags |= FAULT_FLAG_MKWRITE;
|
||||
ret = vma->vm_ops->pfn_mkwrite(vmf);
|
||||
@ -3385,10 +3384,10 @@ static vm_fault_t wp_page_shared(struct vm_fault *vmf)
|
||||
vm_fault_t tmp;
|
||||
|
||||
pte_unmap_unlock(vmf->pte, vmf->ptl);
|
||||
if (vmf->flags & FAULT_FLAG_VMA_LOCK) {
|
||||
tmp = vmf_can_call_fault(vmf);
|
||||
if (tmp) {
|
||||
put_page(vmf->page);
|
||||
vma_end_read(vmf->vma);
|
||||
return VM_FAULT_RETRY;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
tmp = do_page_mkwrite(vmf);
|
||||
|
Loading…
Reference in New Issue
Block a user