generic compat_sys_rt_sigprocmask()
[firefly-linux-kernel-4.4.55.git] / kernel / signal.c
index 372771e948c230141a767003fa0f2e18c0d44db2..bce1222b73159ec5d7877e7394849f5ee8a5d002 100644 (file)
@@ -2613,6 +2613,47 @@ SYSCALL_DEFINE4(rt_sigprocmask, int, how, sigset_t __user *, nset,
        return 0;
 }
 
+#ifdef CONFIG_COMPAT
+#ifdef CONFIG_GENERIC_COMPAT_RT_SIGPROCMASK
+COMPAT_SYSCALL_DEFINE4(rt_sigprocmask, int, how, compat_sigset_t __user *, nset,
+               compat_sigset_t __user *, oset, compat_size_t, sigsetsize)
+{
+#ifdef __BIG_ENDIAN
+       sigset_t old_set = current->blocked;
+
+       /* XXX: Don't preclude handling different sized sigset_t's.  */
+       if (sigsetsize != sizeof(sigset_t))
+               return -EINVAL;
+
+       if (nset) {
+               compat_sigset_t new32;
+               sigset_t new_set;
+               int error;
+               if (copy_from_user(&new32, nset, sizeof(compat_sigset_t)))
+                       return -EFAULT;
+
+               sigset_from_compat(&new_set, &new32);
+               sigdelsetmask(&new_set, sigmask(SIGKILL)|sigmask(SIGSTOP));
+
+               error = sigprocmask(how, &new_set, NULL);
+               if (error)
+                       return error;
+       }
+       if (oset) {
+               compat_sigset_t old32;
+               sigset_to_compat(&old32, &old_set);
+               if (copy_to_user(oset, &old_set, sizeof(sigset_t)))
+                       return -EFAULT;
+       }
+       return 0;
+#else
+       return sys_rt_sigprocmask(how, (sigset_t __user *)nset,
+                                 (sigset_t __user *)oset, sigsetsize);
+#endif
+}
+#endif
+#endif
+
 long do_sigpending(void __user *set, unsigned long sigsetsize)
 {
        long error = -EINVAL;
@@ -3116,8 +3157,9 @@ int __save_altstack(stack_t __user *uss, unsigned long sp)
 
 #ifdef CONFIG_COMPAT
 #ifdef CONFIG_GENERIC_SIGALTSTACK
-asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr,
-                                      compat_stack_t __user *uoss_ptr)
+COMPAT_SYSCALL_DEFINE2(sigaltstack,
+                       const compat_stack_t __user *, uss_ptr,
+                       compat_stack_t __user *, uoss_ptr)
 {
        stack_t uss, uoss;
        int ret;
@@ -3230,7 +3272,7 @@ SYSCALL_DEFINE3(sigprocmask, int, how, old_sigset_t __user *, nset,
 }
 #endif /* __ARCH_WANT_SYS_SIGPROCMASK */
 
-#ifdef __ARCH_WANT_SYS_RT_SIGACTION
+#ifndef CONFIG_ODD_RT_SIGACTION
 /**
  *  sys_rt_sigaction - alter an action taken by a process
  *  @sig: signal to be sent
@@ -3264,7 +3306,7 @@ SYSCALL_DEFINE4(rt_sigaction, int, sig,
 out:
        return ret;
 }
-#endif /* __ARCH_WANT_SYS_RT_SIGACTION */
+#endif /* !CONFIG_ODD_RT_SIGACTION */
 
 #ifdef __ARCH_WANT_SYS_SGETMASK
 
@@ -3351,7 +3393,29 @@ SYSCALL_DEFINE2(rt_sigsuspend, sigset_t __user *, unewset, size_t, sigsetsize)
                return -EFAULT;
        return sigsuspend(&newset);
 }
-#endif /* __ARCH_WANT_SYS_RT_SIGSUSPEND */
+#ifdef CONFIG_COMPAT
+COMPAT_SYSCALL_DEFINE2(rt_sigsuspend, compat_sigset_t __user *, unewset, compat_size_t, sigsetsize)
+{
+#ifdef __BIG_ENDIAN
+       sigset_t newset;
+       compat_sigset_t newset32;
+
+       /* XXX: Don't preclude handling different sized sigset_t's.  */
+       if (sigsetsize != sizeof(sigset_t))
+               return -EINVAL;
+
+       if (copy_from_user(&newset32, unewset, sizeof(compat_sigset_t)))
+               return -EFAULT;
+       sigset_from_compat(&newset, &newset32);
+       return sigsuspend(&newset);
+#else
+       /* on little-endian bitmaps don't care about granularity */
+       return sys_rt_sigsuspend((sigset_t __user *)unewset, sigsetsize);
+#endif
+}
+#endif
+#endif
 
 __attribute__((weak)) const char *arch_vma_name(struct vm_area_struct *vma)
 {