]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[S390] mm: handle kernel caused page fault oom situations
authorHeiko Carstens <heiko.carstens@de.ibm.com>
Thu, 26 May 2011 07:48:29 +0000 (09:48 +0200)
committerHeiko Carstens <heiko.carstens@de.ibm.com>
Thu, 26 May 2011 07:48:25 +0000 (09:48 +0200)
If e.g. copy_from_user() generates a page fault and the kernel runs
into an OOM situation the system might lock up.
If the OOM killer sends a SIG_KILL to the current process it can't
handle it since it is stuck in a copy_from_user() - page fault loop.

Fix this by adding the same fix as other architectures have.

E.g. the x86 variant f86268 "x86/mm: Handle mm_fault_error() in kernel
space"

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
arch/s390/mm/fault.c

index 105fa107143568800b5451455c00f7b803c76658..b57723aee848f634a03d51ff4bcbc140f5505424 100644 (file)
@@ -245,9 +245,12 @@ static noinline void do_fault_error(struct pt_regs *regs, long int_code,
                do_no_context(regs, int_code, trans_exc_code);
                break;
        default: /* fault & VM_FAULT_ERROR */
-               if (fault & VM_FAULT_OOM)
-                       pagefault_out_of_memory();
-               else if (fault & VM_FAULT_SIGBUS) {
+               if (fault & VM_FAULT_OOM) {
+                       if (!(regs->psw.mask & PSW_MASK_PSTATE))
+                               do_no_context(regs, int_code, trans_exc_code);
+                       else
+                               pagefault_out_of_memory();
+               } else if (fault & VM_FAULT_SIGBUS) {
                        /* Kernel mode? Handle exceptions or die */
                        if (!(regs->psw.mask & PSW_MASK_PSTATE))
                                do_no_context(regs, int_code, trans_exc_code);
@@ -429,10 +432,9 @@ int __handle_fault(unsigned long uaddr, unsigned long pgm_int_code, int write)
        access = write ? VM_WRITE : VM_READ;
        fault = do_exception(&regs, access, uaddr | 2);
        if (unlikely(fault)) {
-               if (fault & VM_FAULT_OOM) {
-                       pagefault_out_of_memory();
-                       fault = 0;
-               } else if (fault & VM_FAULT_SIGBUS)
+               if (fault & VM_FAULT_OOM)
+                       return -EFAULT;
+               else if (fault & VM_FAULT_SIGBUS)
                        do_sigbus(&regs, pgm_int_code, uaddr);
        }
        return fault ? -EFAULT : 0;