]> git.hungrycats.org Git - linux/commitdiff
mm: make the page fault mmap locking killable
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 15 Jun 2023 23:17:48 +0000 (16:17 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 1 Jul 2023 11:14:45 +0000 (13:14 +0200)
commit eda0047296a16d65a7f2bc60a408f70d178b2014 upstream.

This is done as a separate patch from introducing the new
lock_mm_and_find_vma() helper, because while it's an obvious change,
it's not what x86 used to do in this area.

We already abort the page fault on fatal signals anyway, so why should
we wait for the mmap lock only to then abort later? With the new helper
function that returns without the lock held on failure anyway, this is
particularly easy and straightforward.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
mm/memory.c

index 9ee62d7daf459036e87661d7e7b2657c5f8fc906..54d5e7217d4dd3f278b40918db2b1e036a8739dc 100644 (file)
@@ -5247,8 +5247,7 @@ static inline bool get_mmap_lock_carefully(struct mm_struct *mm, struct pt_regs
                        return false;
        }
 
-       mmap_read_lock(mm);
-       return true;
+       return !mmap_read_lock_killable(mm);
 }
 
 static inline bool mmap_upgrade_trylock(struct mm_struct *mm)
@@ -5272,8 +5271,7 @@ static inline bool upgrade_mmap_lock_carefully(struct mm_struct *mm, struct pt_r
                if (!search_exception_tables(ip))
                        return false;
        }
-       mmap_write_lock(mm);
-       return true;
+       return !mmap_write_lock_killable(mm);
 }
 
 /*