new helper: restore_altstack()
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / kernel / signal.c
index 0af8868525d6d1853acfa77eb9f224566ccfb313..887f2fefe207e171d2fbede1a7c651a4db66d674 100644 (file)
@@ -1159,8 +1159,9 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
        return __send_signal(sig, info, t, group, from_ancestor_ns);
 }
 
-static void print_fatal_signal(struct pt_regs *regs, int signr)
+static void print_fatal_signal(int signr)
 {
+       struct pt_regs *regs = signal_pt_regs();
        printk("%s/%d: potentially unexpected fatal signal %d.\n",
                current->comm, task_pid_nr(current), signr);
 
@@ -2138,10 +2139,9 @@ static void do_jobctl_trap(void)
        }
 }
 
-static int ptrace_signal(int signr, siginfo_t *info,
-                        struct pt_regs *regs, void *cookie)
+static int ptrace_signal(int signr, siginfo_t *info)
 {
-       ptrace_signal_deliver(regs, cookie);
+       ptrace_signal_deliver();
        /*
         * We do not check sig_kernel_stop(signr) but set this marker
         * unconditionally because we do not know whether debugger will
@@ -2265,8 +2265,7 @@ relock:
                        break; /* will return 0 */
 
                if (unlikely(current->ptrace) && signr != SIGKILL) {
-                       signr = ptrace_signal(signr, info,
-                                             regs, cookie);
+                       signr = ptrace_signal(signr, info);
                        if (!signr)
                                continue;
                }
@@ -2351,7 +2350,7 @@ relock:
 
                if (sig_kernel_coredump(signr)) {
                        if (print_fatal_signals)
-                               print_fatal_signal(regs, info->si_signo);
+                               print_fatal_signal(info->si_signo);
                        /*
                         * If it was able to dump core, this kills all
                         * other threads in the group and synchronizes with
@@ -2360,7 +2359,7 @@ relock:
                         * first and our do_group_exit call below will use
                         * that value and ignore the one we pass it.
                         */
-                       do_coredump(info, regs);
+                       do_coredump(info);
                }
 
                /*
@@ -3104,6 +3103,13 @@ out:
        return error;
 }
 
+int restore_altstack(const stack_t __user *uss)
+{
+       int err = do_sigaltstack(uss, NULL, current_user_stack_pointer());
+       /* squash all but EFAULT for now */
+       return err == -EFAULT ? err : 0;
+}
+
 #ifdef __ARCH_WANT_SYS_SIGPENDING
 
 /**