@@ -84,11 +84,6 @@ static int __bad_area(struct pt_regs *regs, unsigned long address, int si_code)
8484 return __bad_area_nosemaphore (regs , address , si_code );
8585}
8686
87- static noinline int bad_area (struct pt_regs * regs , unsigned long address )
88- {
89- return __bad_area (regs , address , SEGV_MAPERR );
90- }
91-
9287static noinline int bad_access_pkey (struct pt_regs * regs , unsigned long address ,
9388 struct vm_area_struct * vma )
9489{
@@ -515,40 +510,12 @@ static int ___do_page_fault(struct pt_regs *regs, unsigned long address,
515510 * we will deadlock attempting to validate the fault against the
516511 * address space. Luckily the kernel only validly references user
517512 * space from well defined areas of code, which are listed in the
518- * exceptions table.
519- *
520- * As the vast majority of faults will be valid we will only perform
521- * the source reference check when there is a possibility of a deadlock.
522- * Attempt to lock the address space, if we cannot we then validate the
523- * source. If this is invalid we can skip the address space check,
524- * thus avoiding the deadlock.
513+ * exceptions table. lock_mm_and_find_vma() handles that logic.
525514 */
526- if (unlikely (!mmap_read_trylock (mm ))) {
527- if (!is_user && !search_exception_tables (regs -> nip ))
528- return bad_area_nosemaphore (regs , address );
529-
530515retry :
531- mmap_read_lock (mm );
532- } else {
533- /*
534- * The above down_read_trylock() might have succeeded in
535- * which case we'll have missed the might_sleep() from
536- * down_read():
537- */
538- might_sleep ();
539- }
540-
541- vma = find_vma (mm , address );
516+ vma = lock_mm_and_find_vma (mm , address , regs );
542517 if (unlikely (!vma ))
543- return bad_area (regs , address );
544-
545- if (unlikely (vma -> vm_start > address )) {
546- if (unlikely (!(vma -> vm_flags & VM_GROWSDOWN )))
547- return bad_area (regs , address );
548-
549- if (unlikely (expand_stack (vma , address )))
550- return bad_area (regs , address );
551- }
518+ return bad_area_nosemaphore (regs , address );
552519
553520 if (unlikely (access_pkey_error (is_write , is_exec ,
554521 (error_code & DSISR_KEYFAULT ), vma )))
0 commit comments