~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/parisc/kernel/signal32.c

Version: ~ [ linux-5.8 ] ~ [ linux-5.7.14 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.57 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.138 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.193 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.232 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.232 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* mostly borrowed from kernel/signal.c */
  2 #include <linux/config.h>
  3 #include <linux/compat.h>
  4 #include <linux/slab.h>
  5 #include <linux/module.h>
  6 #include <linux/unistd.h>
  7 #include <linux/smp_lock.h>
  8 #include <linux/init.h>
  9 #include <linux/sched.h>
 10 #include <linux/types.h>
 11 #include <linux/errno.h>
 12 
 13 #include <asm/uaccess.h>
 14 #include "sys32.h"
 15 
 16 struct k_sigaction32 {
 17         struct sigaction32 sa;
 18 };
 19 
 20 static inline void
 21 sigset_32to64(sigset_t *s64, compat_sigset_t *s32)
 22 {
 23         s64->sig[0] = s32->sig[0] | ((unsigned long)s32->sig[1] << 32);
 24 }
 25 
 26 static inline void
 27 sigset_64to32(compat_sigset_t *s32, sigset_t *s64)
 28 {
 29         s32->sig[0] = s64->sig[0] & 0xffffffffUL;
 30         s32->sig[1] = (s64->sig[0] >> 32) & 0xffffffffUL;
 31 }
 32 
 33 static int
 34 put_sigset32(compat_sigset_t *up, sigset_t *set, size_t sz)
 35 {
 36         compat_sigset_t s;
 37 
 38         if (sz != sizeof *set) panic("put_sigset32()");
 39         sigset_64to32(&s, set);
 40 
 41         return copy_to_user(up, &s, sizeof s);
 42 }
 43 
 44 static int
 45 get_sigset32(compat_sigset_t *up, sigset_t *set, size_t sz)
 46 {
 47         compat_sigset_t s;
 48         int r;
 49 
 50         if (sz != sizeof *set) panic("put_sigset32()");
 51 
 52         if ((r = copy_from_user(&s, up, sz)) == 0) {
 53                 sigset_32to64(set, &s);
 54         }
 55 
 56         return r;
 57 }
 58 
 59 int sys32_rt_sigprocmask(int how, compat_sigset_t *set, compat_sigset_t *oset,
 60                                     unsigned int sigsetsize)
 61 {
 62         extern long sys_rt_sigprocmask(int how,
 63                                     sigset_t *set, sigset_t *oset,
 64                                    size_t sigsetsize);
 65         sigset_t old_set, new_set;
 66         int ret;
 67 
 68         if (set && get_sigset32(set, &new_set, sigsetsize))
 69                 return -EFAULT;
 70         
 71         KERNEL_SYSCALL(ret, sys_rt_sigprocmask, how, set ? &new_set : NULL,
 72                                  oset ? &old_set : NULL, sigsetsize);
 73 
 74         if (!ret && oset && put_sigset32(oset, &old_set, sigsetsize))
 75                 return -EFAULT;
 76 
 77         return ret;
 78 }
 79 
 80 
 81 int sys32_rt_sigpending(compat_sigset_t *uset, unsigned int sigsetsize)
 82 {
 83         int ret;
 84         sigset_t set;
 85         extern long sys_rt_sigpending(sigset_t *set, size_t sigsetsize);
 86 
 87         KERNEL_SYSCALL(ret, sys_rt_sigpending, &set, sigsetsize);
 88 
 89         if (!ret && put_sigset32(uset, &set, sigsetsize))
 90                 return -EFAULT;
 91 
 92         return ret;
 93 }
 94 
 95 long
 96 sys32_rt_sigaction(int sig, const struct sigaction32 *act, struct sigaction32 *oact,
 97                  size_t sigsetsize)
 98 {
 99         struct k_sigaction32 new_sa32, old_sa32;
100         struct k_sigaction new_sa, old_sa;
101         int ret = -EINVAL;
102 
103         if (act) {
104                 if (copy_from_user(&new_sa32.sa, act, sizeof new_sa32.sa))
105                         return -EFAULT;
106                 new_sa.sa.sa_handler = (__sighandler_t)(unsigned long)new_sa32.sa.sa_handler;
107                 new_sa.sa.sa_flags = new_sa32.sa.sa_flags;
108                 sigset_32to64(&new_sa.sa.sa_mask, &new_sa32.sa.sa_mask);
109         }
110 
111         ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa : NULL);
112 
113         if (!ret && oact) {
114                 sigset_64to32(&old_sa32.sa.sa_mask, &old_sa.sa.sa_mask);
115                 old_sa32.sa.sa_flags = old_sa.sa.sa_flags;
116                 old_sa32.sa.sa_handler = (__sighandler_t32)(unsigned long)old_sa.sa.sa_handler;
117                 if (copy_to_user(oact, &old_sa32.sa, sizeof old_sa32.sa))
118                         return -EFAULT;
119         }
120         return ret;
121 }
122 
123 typedef struct {
124         unsigned int ss_sp;
125         int ss_flags;
126         compat_size_t ss_size;
127 } stack_t32;
128 
129 int 
130 do_sigaltstack32 (const stack_t32 *uss32, stack_t32 *uoss32, unsigned long sp)
131 {
132         stack_t32 ss32, oss32;
133         stack_t ss, oss;
134         stack_t *ssp = NULL, *ossp = NULL;
135         int ret;
136 
137         if (uss32) {
138                 if (copy_from_user(&ss32, uss32, sizeof ss32))
139                         return -EFAULT;
140 
141                 ss.ss_sp = (void *)(unsigned long)ss32.ss_sp;
142                 ss.ss_flags = ss32.ss_flags;
143                 ss.ss_size = ss32.ss_size;
144 
145                 ssp = &ss;
146         }
147 
148         if (uoss32)
149                 ossp = &oss;
150 
151         KERNEL_SYSCALL(ret, do_sigaltstack, ssp, ossp, sp);
152 
153         if (!ret && uoss32) {
154                 oss32.ss_sp = (unsigned int)(unsigned long)oss.ss_sp;
155                 oss32.ss_flags = oss.ss_flags;
156                 oss32.ss_size = oss.ss_size;
157                 if (copy_to_user(uoss32, &oss32, sizeof *uoss32))
158                         return -EFAULT;
159         }
160 
161         return ret;
162 }
163 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp