Commit f8626854 authored by Andrey Vagin's avatar Andrey Vagin Committed by Ingo Molnar
Browse files

x86/mm: Handle mm_fault_error() in kernel space

mm_fault_error() should not execute oom-killer, if page fault
occurs in kernel space.  E.g. in copy_from_user()/copy_to_user().

This would happen if we find ourselves in OOM on a
copy_to_user(), or a copy_from_user() which faults.

Without this patch, the kernels hangs up in copy_from_user(),
because OOM killer sends SIG_KILL to current process, but it
can't handle a signal while in syscall, then the kernel returns
to copy_from_user(), reexcute current command and provokes
page_fault again.

With this patch the kernel return -EFAULT from copy_from_user().

The code, which checks that page fault occurred in kernel space,
has been copied from do_sigbus().

This situation is handled by the same way on powerpc, xtensa,
tile, ...
Signed-off-by: default avatarAndrey Vagin <>
Signed-off-by: default avatarAndrew Morton <>
Cc: "H. Peter Anvin" <>
Cc: Linus Torvalds <>
Cc: <>
LKML-Reference: <>
Signed-off-by: default avatarIngo Molnar <>
parent a7bd1daf
......@@ -828,6 +828,13 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code,
unsigned long address, unsigned int fault)
if (fault & VM_FAULT_OOM) {
/* Kernel mode? Handle exceptions or die: */
if (!(error_code & PF_USER)) {
no_context(regs, error_code, address);
out_of_memory(regs, error_code, address);
} else {
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