Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/hskinnemoen...
[sfrench/cifs-2.6.git] / arch / ia64 / ia32 / ia32_signal.c
index b3355a9ca2c3fb3b3b654dae5f7817936758b47c..256a7faeda0787fc7ba6df9f48d0899dc0add99a 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/sched.h>
 #include <linux/signal.h>
 #include <linux/smp.h>
-#include <linux/smp_lock.h>
 #include <linux/stddef.h>
 #include <linux/syscalls.h>
 #include <linux/unistd.h>
@@ -452,59 +451,20 @@ sigact_set_handler (struct k_sigaction *sa, unsigned int handler, unsigned int r
                sa->sa.sa_handler = (__sighandler_t) (((unsigned long) restorer << 32) | handler);
 }
 
-long
-__ia32_rt_sigsuspend (compat_sigset_t *sset, unsigned int sigsetsize, struct sigscratch *scr)
+asmlinkage long
+sys32_sigsuspend (int history0, int history1, old_sigset_t mask)
 {
-       extern long ia64_do_signal (sigset_t *oldset, struct sigscratch *scr, long in_syscall);
-       sigset_t oldset, set;
-
-       scr->scratch_unat = 0;  /* avoid leaking kernel bits to user level */
-       memset(&set, 0, sizeof(set));
-
-       memcpy(&set.sig, &sset->sig, sigsetsize);
-
-       sigdelsetmask(&set, ~_BLOCKABLE);
-
+       mask &= _BLOCKABLE;
        spin_lock_irq(&current->sighand->siglock);
-       {
-               oldset = current->blocked;
-               current->blocked = set;
-               recalc_sigpending();
-       }
+       current->saved_sigmask = current->blocked;
+       siginitset(&current->blocked, mask);
+       recalc_sigpending();
        spin_unlock_irq(&current->sighand->siglock);
 
-       /*
-        * The return below usually returns to the signal handler.  We need to pre-set the
-        * correct error code here to ensure that the right values get saved in sigcontext
-        * by ia64_do_signal.
-        */
-       scr->pt.r8 = -EINTR;
-       while (1) {
-               current->state = TASK_INTERRUPTIBLE;
-               schedule();
-               if (ia64_do_signal(&oldset, scr, 1))
-                       return -EINTR;
-       }
-}
-
-asmlinkage long
-ia32_rt_sigsuspend (compat_sigset_t __user *uset, unsigned int sigsetsize, struct sigscratch *scr)
-{
-       compat_sigset_t set;
-
-       if (sigsetsize > sizeof(compat_sigset_t))
-               return -EINVAL;
-
-       if (copy_from_user(&set.sig, &uset->sig, sigsetsize))
-               return -EFAULT;
-
-       return __ia32_rt_sigsuspend(&set, sigsetsize, scr);
-}
-
-asmlinkage long
-ia32_sigsuspend (unsigned int mask, struct sigscratch *scr)
-{
-       return __ia32_rt_sigsuspend((compat_sigset_t *) &mask, sizeof(mask), scr);
+       current->state = TASK_INTERRUPTIBLE;
+       schedule();
+       set_thread_flag(TIF_RESTORE_SIGMASK);
+       return -ERESTARTNOHAND;
 }
 
 asmlinkage long
@@ -806,12 +766,27 @@ get_sigframe (struct k_sigaction *ka, struct pt_regs * regs, size_t frame_size)
 
        /* This is the X/Open sanctioned signal stack switching.  */
        if (ka->sa.sa_flags & SA_ONSTACK) {
-               if (!on_sig_stack(esp))
+               int onstack = sas_ss_flags(esp);
+
+               if (onstack == 0)
                        esp = current->sas_ss_sp + current->sas_ss_size;
+               else if (onstack == SS_ONSTACK) {
+                       /*
+                        * 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.
+                        */
+                       if (!likely(on_sig_stack(esp - frame_size)))
+                               return (void __user *) -1L;
+               }
        }
        /* Legacy stack switching not supported */
 
-       return (void __user *)((esp - frame_size) & -8ul);
+       esp -= frame_size;
+       /* Align the stack pointer according to the i386 ABI,
+        * i.e. so that on function entry ((sp + 4) & 15) == 0. */
+       esp = ((esp + 4) & -16ul) - 4;
+       return (void __user *) esp;
 }
 
 static int