@@ -84,11 +84,6 @@ static int __bad_area(struct pt_regs *regs, unsigned long address, int si_code)
84
84
return __bad_area_nosemaphore (regs , address , si_code );
85
85
}
86
86
87
- static noinline int bad_area (struct pt_regs * regs , unsigned long address )
88
- {
89
- return __bad_area (regs , address , SEGV_MAPERR );
90
- }
91
-
92
87
static noinline int bad_access_pkey (struct pt_regs * regs , unsigned long address ,
93
88
struct vm_area_struct * vma )
94
89
{
@@ -481,40 +476,12 @@ static int ___do_page_fault(struct pt_regs *regs, unsigned long address,
481
476
* we will deadlock attempting to validate the fault against the
482
477
* address space. Luckily the kernel only validly references user
483
478
* space from well defined areas of code, which are listed in the
484
- * exceptions table.
485
- *
486
- * As the vast majority of faults will be valid we will only perform
487
- * the source reference check when there is a possibility of a deadlock.
488
- * Attempt to lock the address space, if we cannot we then validate the
489
- * source. If this is invalid we can skip the address space check,
490
- * thus avoiding the deadlock.
479
+ * exceptions table. lock_mm_and_find_vma() handles that logic.
491
480
*/
492
- if (unlikely (!mmap_read_trylock (mm ))) {
493
- if (!is_user && !search_exception_tables (regs -> nip ))
494
- return bad_area_nosemaphore (regs , address );
495
-
496
481
retry :
497
- mmap_read_lock (mm );
498
- } else {
499
- /*
500
- * The above down_read_trylock() might have succeeded in
501
- * which case we'll have missed the might_sleep() from
502
- * down_read():
503
- */
504
- might_sleep ();
505
- }
506
-
507
- vma = find_vma (mm , address );
482
+ vma = lock_mm_and_find_vma (mm , address , regs );
508
483
if (unlikely (!vma ))
509
- return bad_area (regs , address );
510
-
511
- if (unlikely (vma -> vm_start > address )) {
512
- if (unlikely (!(vma -> vm_flags & VM_GROWSDOWN )))
513
- return bad_area (regs , address );
514
-
515
- if (unlikely (expand_stack (vma , address )))
516
- return bad_area (regs , address );
517
- }
484
+ return bad_area_nosemaphore (regs , address );
518
485
519
486
if (unlikely (access_pkey_error (is_write , is_exec ,
520
487
(error_code & DSISR_KEYFAULT ), vma )))
0 commit comments