]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: prevent userfaults to be handled under per-vma lock
authorSuren Baghdasaryan <surenb@google.com>
Sun, 30 Oct 2022 17:34:25 +0000 (17:34 +0000)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 4 Jan 2023 20:59:26 +0000 (15:59 -0500)
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.

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Suggested-by: Peter Xu <peterx@redhat.com>
mm/memory.c

index f528d0ea3671b85812c54421903e83ae4bbb4013..e618481d6b528b99146afedc929fb810a5f46f17 100644 (file)
@@ -5267,6 +5267,13 @@ retry:
        if (!vma_is_anonymous(vma))
                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))
+               goto inval;
+
        if (!vma_read_trylock(vma)) {
                count_vm_vma_lock_event(VMA_LOCK_ABORT);
                goto inval;