]> 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)
committerSuren Baghdasaryan <surenb@google.com>
Wed, 23 Nov 2022 02:09:46 +0000 (02:09 +0000)
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 57279e03f8885bc775a59bdc36094f2904279f12..a4982e16cf19fc0526457d88e6b6257be1b429e0 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;