mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-05 00:20:32 +00:00
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: Andy Lutomirski <luto@kernel.org> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lkml.kernel.org/r/6e3d1129494a8de1e59d28012286e3a292a2296e.1612924255.git.luto@kernel.org
This commit is contained in:
parent
2cc624b0a7
commit
5042d40a26
1 changed files with 40 additions and 35 deletions
|
@ -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,
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue