Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 840ff6a4 authored by Russell King's avatar Russell King Committed by Russell King
Browse files

[ARM] Prevent deadlock in page fault handler



As per x86, we may deadlock while trying to get the mmap semaphore.
Implement the same fix, which allows (eg) recursive faults to cause
an oops instead of deadlocking.

Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 5fe10ab1
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -233,7 +233,17 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
	if (in_interrupt() || !mm)
		goto no_context;

	/*
	 * As per x86, we may deadlock here.  However, since the kernel only
	 * validly references user space from well defined areas of the code,
	 * we can bug out early if this is from code which shouldn't.
	 */
	if (!down_read_trylock(&mm->mmap_sem)) {
		if (!user_mode(regs) && !search_exception_tables(regs->ARM_pc))
			goto no_context;
		down_read(&mm->mmap_sem);
	}

	fault = __do_page_fault(mm, addr, fsr, tsk);
	up_read(&mm->mmap_sem);