mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
UPSTREAM: mm: prevent userfaults to be handled under per-vma lock
Due to the possibility of handle_userfault dropping mmap_lock, avoid fault
handling under VMA lock and retry holding mmap_lock. This can be handled
more gracefully in the future.
Link: https://lkml.kernel.org/r/20230227173632.3292573-28-surenb@google.com
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Suggested-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 444eeb1743)
Bug: 161210518
Change-Id: I383603d637497ea9917ad08908530f91052a17cc
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
committed by
Carlos Llamas
parent
6e306e82ac
commit
4e4c6989ae
@@ -5296,6 +5296,15 @@ retry:
|
|||||||
if (!vma_start_read(vma))
|
if (!vma_start_read(vma))
|
||||||
goto inval;
|
goto inval;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Due to the possibility of userfault handler dropping mmap_lock, avoid
|
||||||
|
* it for now and fall back to page fault handling under mmap_lock.
|
||||||
|
*/
|
||||||
|
if (userfaultfd_armed(vma)) {
|
||||||
|
vma_end_read(vma);
|
||||||
|
goto inval;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check since vm_start/vm_end might change before we lock the VMA */
|
/* Check since vm_start/vm_end might change before we lock the VMA */
|
||||||
if (unlikely(address < vma->vm_start || address >= vma->vm_end)) {
|
if (unlikely(address < vma->vm_start || address >= vma->vm_end)) {
|
||||||
vma_end_read(vma);
|
vma_end_read(vma);
|
||||||
|
|||||||
Reference in New Issue
Block a user