Skip to content

Commit 82972ea

Browse files
mpegregkh
authored andcommitted
powerpc/mm: Convert to using lock_mm_and_find_vma()
commit e6fe228 upstream. Signed-off-by: Michael Ellerman <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Samuel Mendoza-Jonas <[email protected]> Signed-off-by: David Woodhouse <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b92cd80 commit 82972ea

File tree

2 files changed

+4
-36
lines changed

2 files changed

+4
-36
lines changed

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ config PPC
257257
select IRQ_DOMAIN
258258
select IRQ_FORCED_THREADING
259259
select KASAN_VMALLOC if KASAN && MODULES
260+
select LOCK_MM_AND_FIND_VMA
260261
select MMU_GATHER_PAGE_SIZE
261262
select MMU_GATHER_RCU_TABLE_FREE
262263
select MMU_GATHER_MERGE_VMAS

arch/powerpc/mm/fault.c

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
9287
static noinline int bad_access_pkey(struct pt_regs *regs, unsigned long address,
9388
struct vm_area_struct *vma)
9489
{
@@ -481,40 +476,12 @@ static int ___do_page_fault(struct pt_regs *regs, unsigned long address,
481476
* we will deadlock attempting to validate the fault against the
482477
* address space. Luckily the kernel only validly references user
483478
* 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.
491480
*/
492-
if (unlikely(!mmap_read_trylock(mm))) {
493-
if (!is_user && !search_exception_tables(regs->nip))
494-
return bad_area_nosemaphore(regs, address);
495-
496481
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);
508483
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);
518485

519486
if (unlikely(access_pkey_error(is_write, is_exec,
520487
(error_code & DSISR_KEYFAULT), vma)))

0 commit comments

Comments
 (0)