* [tip:x86/urgent] x86/mm: Handle mm_fault_error() in kernel space
[not found] <201103092322.p29NMNPH001682@imap1.linux-foundation.org>
@ 2011-03-10 14:21 ` tip-bot for Andrey Vagin
0 siblings, 0 replies; only message in thread
From: tip-bot for Andrey Vagin @ 2011-03-10 14:21 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, torvalds, avagin, akpm, stable, tglx, mingo
Commit-ID: f86268549f424f83b9eb0963989270e14fbfc3de
Gitweb: http://git.kernel.org/tip/f86268549f424f83b9eb0963989270e14fbfc3de
Author: Andrey Vagin <avagin@openvz.org>
AuthorDate: Wed, 9 Mar 2011 15:22:23 -0800
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 10 Mar 2011 09:41:40 +0100
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>
---
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 7d90ceb..ffc7be1 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,
unsigned long address, unsigned int fault)
{
if (fault & VM_FAULT_OOM) {
+ /* Kernel mode? Handle exceptions or die: */
+ if (!(error_code & PF_USER)) {
+ up_read(¤t->mm->mmap_sem);
+ no_context(regs, error_code, address);
+ return;
+ }
+
out_of_memory(regs, error_code, address);
} else {
if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON|
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-03-10 14:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <201103092322.p29NMNPH001682@imap1.linux-foundation.org>
2011-03-10 14:21 ` [tip:x86/urgent] x86/mm: Handle mm_fault_error() in kernel space tip-bot for Andrey Vagin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®