]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/ia64/kernel/signal.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
[linux-2.6-omap-h63xx.git] / arch / ia64 / kernel / signal.c
index 309da3567bc851966e8a7ad27e01eccac2e26ff2..e12500a9c44390b025feeb0b670baac1c1ffd523 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/ptrace.h>
+#include <linux/tracehook.h>
 #include <linux/sched.h>
 #include <linux/signal.h>
 #include <linux/smp.h>
@@ -342,15 +343,33 @@ setup_frame (int sig, struct k_sigaction *ka, siginfo_t *info, sigset_t *set,
 
        new_sp = scr->pt.r12;
        tramp_addr = (unsigned long) __kernel_sigtramp;
-       if ((ka->sa.sa_flags & SA_ONSTACK) && sas_ss_flags(new_sp) == 0) {
-               new_sp = current->sas_ss_sp + current->sas_ss_size;
-               /*
-                * We need to check for the register stack being on the signal stack
-                * separately, because it's switched separately (memory stack is switched
-                * in the kernel, register stack is switched in the signal trampoline).
-                */
-               if (!rbs_on_sig_stack(scr->pt.ar_bspstore))
-                       new_rbs = (current->sas_ss_sp + sizeof(long) - 1) & ~(sizeof(long) - 1);
+       if (ka->sa.sa_flags & SA_ONSTACK) {
+               int onstack = sas_ss_flags(new_sp);
+
+               if (onstack == 0) {
+                       new_sp = current->sas_ss_sp + current->sas_ss_size;
+                       /*
+                        * We need to check for the register stack being on the
+                        * signal stack separately, because it's switched
+                        * separately (memory stack is switched in the kernel,
+                        * register stack is switched in the signal trampoline).
+                        */
+                       if (!rbs_on_sig_stack(scr->pt.ar_bspstore))
+                               new_rbs = ALIGN(current->sas_ss_sp,
+                                               sizeof(long));
+               } else if (onstack == SS_ONSTACK) {
+                       unsigned long check_sp;
+
+                       /*
+                        * If we are on the alternate signal stack and would
+                        * overflow it, don't. Return an always-bogus address
+                        * instead so we will die with SIGSEGV.
+                        */
+                       check_sp = (new_sp - sizeof(*frame)) & -STACK_ALIGN;
+                       if (!likely(on_sig_stack(check_sp)))
+                               return force_sigsegv_info(sig, (void __user *)
+                                                         check_sp);
+               }
        }
        frame = (void __user *) ((new_sp - sizeof(*frame)) & -STACK_ALIGN);
 
@@ -421,6 +440,13 @@ handle_signal (unsigned long sig, struct k_sigaction *ka, siginfo_t *info, sigse
                sigaddset(&current->blocked, sig);
        recalc_sigpending();
        spin_unlock_irq(&current->sighand->siglock);
+
+       /*
+        * Let tracing know that we've done the handler setup.
+        */
+       tracehook_signal_handler(sig, info, ka, &scr->pt,
+                                test_thread_flag(TIF_SINGLESTEP));
+
        return 1;
 }
 
@@ -446,7 +472,7 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall)
        if (!user_mode(&scr->pt))
                return;
 
-       if (test_thread_flag(TIF_RESTORE_SIGMASK))
+       if (current_thread_info()->status & TS_RESTORE_SIGMASK)
                oldset = &current->saved_sigmask;
        else
                oldset = &current->blocked;
@@ -512,12 +538,13 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall)
                 * continue to iterate in this loop so we can deliver the SIGSEGV...
                 */
                if (handle_signal(signr, &ka, &info, oldset, scr)) {
-                       /* a signal was successfully delivered; the saved
+                       /*
+                        * A signal was successfully delivered; the saved
                         * sigmask will have been stored in the signal frame,
                         * and will be restored by sigreturn, so we can simply
-                        * clear the TIF_RESTORE_SIGMASK flag */
-                       if (test_thread_flag(TIF_RESTORE_SIGMASK))
-                               clear_thread_flag(TIF_RESTORE_SIGMASK);
+                        * clear the TS_RESTORE_SIGMASK flag.
+                        */
+                       current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
                        return;
                }
        }
@@ -548,8 +575,8 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall)
 
        /* if there's no signal to deliver, we just put the saved sigmask
         * back */
-       if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
-               clear_thread_flag(TIF_RESTORE_SIGMASK);
+       if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
+               current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
                sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
        }
 }