Commit bc793607 authored by Linus Torvalds's avatar Linus Torvalds Committed by Kamal Mostafa

x86: mm: move mmap_sem unlock from mm_fault_error() to caller

commit 7fb08eca upstream.

This replaces four copies in various stages of mm_fault_error() handling
with just a single one.  It will also allow for more natural placement
of the unlocking after some further cleanup.
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent 073a899b
...@@ -833,11 +833,8 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address, ...@@ -833,11 +833,8 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
unsigned int fault) unsigned int fault)
{ {
struct task_struct *tsk = current; struct task_struct *tsk = current;
struct mm_struct *mm = tsk->mm;
int code = BUS_ADRERR; int code = BUS_ADRERR;
up_read(&mm->mmap_sem);
/* Kernel mode? Handle exceptions or die: */ /* Kernel mode? Handle exceptions or die: */
if (!(error_code & PF_USER)) { if (!(error_code & PF_USER)) {
no_context(regs, error_code, address, SIGBUS, BUS_ADRERR); no_context(regs, error_code, address, SIGBUS, BUS_ADRERR);
...@@ -868,7 +865,6 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code, ...@@ -868,7 +865,6 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code,
unsigned long address, unsigned int fault) unsigned long address, unsigned int fault)
{ {
if (fatal_signal_pending(current) && !(error_code & PF_USER)) { if (fatal_signal_pending(current) && !(error_code & PF_USER)) {
up_read(&current->mm->mmap_sem);
no_context(regs, error_code, address, 0, 0); no_context(regs, error_code, address, 0, 0);
return; return;
} }
...@@ -876,14 +872,11 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code, ...@@ -876,14 +872,11 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code,
if (fault & VM_FAULT_OOM) { if (fault & VM_FAULT_OOM) {
/* Kernel mode? Handle exceptions or die: */ /* Kernel mode? Handle exceptions or die: */
if (!(error_code & PF_USER)) { if (!(error_code & PF_USER)) {
up_read(&current->mm->mmap_sem);
no_context(regs, error_code, address, no_context(regs, error_code, address,
SIGSEGV, SEGV_MAPERR); SIGSEGV, SEGV_MAPERR);
return; return;
} }
up_read(&current->mm->mmap_sem);
/* /*
* We ran out of memory, call the OOM killer, and return the * We ran out of memory, call the OOM killer, and return the
* userspace (which will retry the fault, or kill us if we got * userspace (which will retry the fault, or kill us if we got
...@@ -1215,6 +1208,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code) ...@@ -1215,6 +1208,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
return; return;
if (unlikely(fault & VM_FAULT_ERROR)) { if (unlikely(fault & VM_FAULT_ERROR)) {
up_read(&mm->mmap_sem);
mm_fault_error(regs, error_code, address, fault); mm_fault_error(regs, error_code, address, fault);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment