Commit 5042d40a authored by Andy Lutomirski's avatar Andy Lutomirski Committed by Borislav Petkov

x86/fault: Bypass no_context() for implicit kernel faults from usermode

Drop an indentation level and remove the last user_mode(regs) == true
caller of no_context() by directly OOPSing for implicit kernel faults
from usermode.
Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/6e3d1129494a8de1e59d28012286e3a292a2296e.1612924255.git.luto@kernel.org
parent 2cc624b0
...@@ -826,9 +826,19 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, ...@@ -826,9 +826,19 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
{ {
struct task_struct *tsk = current; struct task_struct *tsk = current;
/* User mode accesses just cause a SIGSEGV */ if (!user_mode(regs)) {
if (user_mode(regs) && (error_code & X86_PF_USER)) { no_context(regs, error_code, address, pkey, si_code);
return;
}
if (!(error_code & X86_PF_USER)) {
/* Implicit user access to kernel memory -- just oops */
page_fault_oops(regs, error_code, address);
return;
}
/* /*
* User mode accesses just cause a SIGSEGV.
* It's possible to have interrupts off here: * It's possible to have interrupts off here:
*/ */
local_irq_enable(); local_irq_enable();
...@@ -859,11 +869,6 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, ...@@ -859,11 +869,6 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
force_sig_fault(SIGSEGV, si_code, (void __user *)address); force_sig_fault(SIGSEGV, si_code, (void __user *)address);
local_irq_disable(); local_irq_disable();
return;
}
no_context(regs, error_code, address, SIGSEGV, si_code);
} }
static noinline void static noinline void
......
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