diff options
author | Andrey Vagin <avagin@openvz.org> | 2011-03-09 18:22:23 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-03-10 03:41:40 -0500 |
commit | f86268549f424f83b9eb0963989270e14fbfc3de (patch) | |
tree | 55fb3f1755a5cb8d81daecfef3aa84bb4ea340e8 /arch/x86/mm | |
parent | a7bd1dafdcc13ec7add4aafc927eb5e3a8d597e6 (diff) |
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: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: <stable@kernel.org>
LKML-Reference: <201103092322.p29NMNPH001682@imap1.linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/mm')
-rw-r--r-- | arch/x86/mm/fault.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 7d90ceb882a4..ffc7be104fc2 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c | |||
@@ -828,6 +828,13 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code, | |||
828 | unsigned long address, unsigned int fault) | 828 | unsigned long address, unsigned int fault) |
829 | { | 829 | { |
830 | if (fault & VM_FAULT_OOM) { | 830 | if (fault & VM_FAULT_OOM) { |
831 | /* Kernel mode? Handle exceptions or die: */ | ||
832 | if (!(error_code & PF_USER)) { | ||
833 | up_read(¤t->mm->mmap_sem); | ||
834 | no_context(regs, error_code, address); | ||
835 | return; | ||
836 | } | ||
837 | |||
831 | out_of_memory(regs, error_code, address); | 838 | out_of_memory(regs, error_code, address); |
832 | } else { | 839 | } else { |
833 | if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON| | 840 | if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON| |