2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 1991, 1992 Linus Torvalds
7 * Copyright (C) 1994 - 2000, 2006 Ralf Baechle
8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
10 #include <linux/cache.h>
11 #include <linux/compat.h>
12 #include <linux/sched.h>
14 #include <linux/smp.h>
15 #include <linux/smp_lock.h>
16 #include <linux/kernel.h>
17 #include <linux/signal.h>
18 #include <linux/syscalls.h>
19 #include <linux/errno.h>
20 #include <linux/wait.h>
21 #include <linux/ptrace.h>
22 #include <linux/compat.h>
23 #include <linux/suspend.h>
24 #include <linux/compiler.h>
28 #include <asm/compat-signal.h>
29 #include <linux/bitops.h>
30 #include <asm/cacheflush.h>
32 #include <asm/uaccess.h>
33 #include <asm/ucontext.h>
34 #include <asm/system.h>
38 #include "signal-common.h"
40 #define SI_PAD_SIZE32 ((SI_MAX_SIZE/sizeof(int)) - 3)
42 typedef struct compat_siginfo {
48 int _pad[SI_PAD_SIZE32];
52 compat_pid_t _pid; /* sender's pid */
53 compat_uid_t _uid; /* sender's uid */
58 compat_pid_t _pid; /* which child */
59 compat_uid_t _uid; /* sender's uid */
60 int _status; /* exit code */
61 compat_clock_t _utime;
62 compat_clock_t _stime;
67 compat_pid_t _pid; /* which child */
68 compat_clock_t _utime;
69 int _status; /* exit code */
70 compat_clock_t _stime;
73 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
75 s32 _addr; /* faulting insn/memory ref. */
78 /* SIGPOLL, SIGXFSZ (To do ...) */
80 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
86 timer_t _tid; /* timer id */
87 int _overrun; /* overrun count */
88 compat_sigval_t _sigval;/* same as below */
89 int _sys_private; /* not to be passed to user */
92 /* POSIX.1b signals */
94 compat_pid_t _pid; /* sender's pid */
95 compat_uid_t _uid; /* sender's uid */
96 compat_sigval_t _sigval;
103 * Including <asm/unistd.h> would give use the 64-bit syscall numbers ...
105 #define __NR_O32_sigreturn 4119
106 #define __NR_O32_rt_sigreturn 4193
107 #define __NR_O32_restart_syscall 4253
109 /* 32-bit compatibility types */
111 #define _NSIG_BPW32 32
112 #define _NSIG_WORDS32 (_NSIG / _NSIG_BPW32)
115 unsigned int sig[_NSIG_WORDS32];
118 typedef unsigned int __sighandler32_t;
119 typedef void (*vfptr_t)(void);
122 unsigned int sa_flags;
123 __sighandler32_t sa_handler;
124 compat_sigset_t sa_mask;
127 /* IRIX compatible stack_t */
128 typedef struct sigaltstack32 {
130 compat_size_t ss_size;
138 struct sigcontext32 uc_mcontext;
139 sigset_t32 uc_sigmask; /* mask last for extensibility */
143 * Horribly complicated - with the bloody RM9000 workarounds enabled
144 * the signal trampolines is moving to the end of the structure so we can
145 * increase the alignment without breaking software compatibility.
147 #if ICACHE_REFILLS_WORKAROUND_WAR == 0
150 u32 sf_ass[4]; /* argument save space for o32 */
151 u32 sf_code[2]; /* signal trampoline */
152 struct sigcontext32 sf_sc;
156 struct rt_sigframe32 {
157 u32 rs_ass[4]; /* argument save space for o32 */
158 u32 rs_code[2]; /* signal trampoline */
159 compat_siginfo_t rs_info;
160 struct ucontext32 rs_uc;
163 #else /* ICACHE_REFILLS_WORKAROUND_WAR */
166 u32 sf_ass[4]; /* argument save space for o32 */
168 struct sigcontext32 sf_sc; /* hw context */
170 u32 sf_code[8] ____cacheline_aligned; /* signal trampoline */
173 struct rt_sigframe32 {
174 u32 rs_ass[4]; /* argument save space for o32 */
176 compat_siginfo_t rs_info;
177 struct ucontext32 rs_uc;
178 u32 rs_code[8] __attribute__((aligned(32))); /* signal trampoline */
181 #endif /* !ICACHE_REFILLS_WORKAROUND_WAR */
184 * sigcontext handlers
186 static int setup_sigcontext32(struct pt_regs *regs,
187 struct sigcontext32 __user *sc)
192 err |= __put_user(regs->cp0_epc, &sc->sc_pc);
194 err |= __put_user(0, &sc->sc_regs[0]);
195 for (i = 1; i < 32; i++)
196 err |= __put_user(regs->regs[i], &sc->sc_regs[i]);
198 err |= __put_user(regs->hi, &sc->sc_mdhi);
199 err |= __put_user(regs->lo, &sc->sc_mdlo);
201 err |= __put_user(rddsp(DSP_MASK), &sc->sc_dsp);
202 err |= __put_user(mfhi1(), &sc->sc_hi1);
203 err |= __put_user(mflo1(), &sc->sc_lo1);
204 err |= __put_user(mfhi2(), &sc->sc_hi2);
205 err |= __put_user(mflo2(), &sc->sc_lo2);
206 err |= __put_user(mfhi3(), &sc->sc_hi3);
207 err |= __put_user(mflo3(), &sc->sc_lo3);
210 err |= __put_user(!!used_math(), &sc->sc_used_math);
214 * Save FPU state to signal context. Signal handler
215 * will "inherit" current FPU state.
219 if (!is_fpu_owner()) {
223 err |= save_fp_context32(sc);
230 static int restore_sigcontext32(struct pt_regs *regs,
231 struct sigcontext32 __user *sc)
238 /* Always make any pending restarted system calls return -EINTR */
239 current_thread_info()->restart_block.fn = do_no_restart_syscall;
241 err |= __get_user(regs->cp0_epc, &sc->sc_pc);
242 err |= __get_user(regs->hi, &sc->sc_mdhi);
243 err |= __get_user(regs->lo, &sc->sc_mdlo);
245 err |= __get_user(treg, &sc->sc_hi1); mthi1(treg);
246 err |= __get_user(treg, &sc->sc_lo1); mtlo1(treg);
247 err |= __get_user(treg, &sc->sc_hi2); mthi2(treg);
248 err |= __get_user(treg, &sc->sc_lo2); mtlo2(treg);
249 err |= __get_user(treg, &sc->sc_hi3); mthi3(treg);
250 err |= __get_user(treg, &sc->sc_lo3); mtlo3(treg);
251 err |= __get_user(treg, &sc->sc_dsp); wrdsp(treg, DSP_MASK);
254 for (i = 1; i < 32; i++)
255 err |= __get_user(regs->regs[i], &sc->sc_regs[i]);
257 err |= __get_user(used_math, &sc->sc_used_math);
258 conditional_used_math(used_math);
263 /* restore fpu context if we have used it before */
265 err |= restore_fp_context32(sc);
267 /* signal handler may have used FPU. Give it up. */
279 extern void __put_sigset_unknown_nsig(void);
280 extern void __get_sigset_unknown_nsig(void);
282 static inline int put_sigset(const sigset_t *kbuf, compat_sigset_t __user *ubuf)
286 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(*ubuf)))
289 switch (_NSIG_WORDS) {
291 __put_sigset_unknown_nsig();
293 err |= __put_user (kbuf->sig[1] >> 32, &ubuf->sig[3]);
294 err |= __put_user (kbuf->sig[1] & 0xffffffff, &ubuf->sig[2]);
296 err |= __put_user (kbuf->sig[0] >> 32, &ubuf->sig[1]);
297 err |= __put_user (kbuf->sig[0] & 0xffffffff, &ubuf->sig[0]);
303 static inline int get_sigset(sigset_t *kbuf, const compat_sigset_t __user *ubuf)
306 unsigned long sig[4];
308 if (!access_ok(VERIFY_READ, ubuf, sizeof(*ubuf)))
311 switch (_NSIG_WORDS) {
313 __get_sigset_unknown_nsig();
315 err |= __get_user (sig[3], &ubuf->sig[3]);
316 err |= __get_user (sig[2], &ubuf->sig[2]);
317 kbuf->sig[1] = sig[2] | (sig[3] << 32);
319 err |= __get_user (sig[1], &ubuf->sig[1]);
320 err |= __get_user (sig[0], &ubuf->sig[0]);
321 kbuf->sig[0] = sig[0] | (sig[1] << 32);
328 * Atomically swap in the new signal mask, and wait for a signal.
331 asmlinkage int sys32_sigsuspend(nabi_no_regargs struct pt_regs regs)
333 compat_sigset_t __user *uset;
336 uset = (compat_sigset_t __user *) regs.regs[4];
337 if (get_sigset(&newset, uset))
339 sigdelsetmask(&newset, ~_BLOCKABLE);
341 spin_lock_irq(¤t->sighand->siglock);
342 current->saved_sigmask = current->blocked;
343 current->blocked = newset;
345 spin_unlock_irq(¤t->sighand->siglock);
347 current->state = TASK_INTERRUPTIBLE;
349 set_thread_flag(TIF_RESTORE_SIGMASK);
350 return -ERESTARTNOHAND;
353 asmlinkage int sys32_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
355 compat_sigset_t __user *uset;
359 /* XXX Don't preclude handling different sized sigset_t's. */
360 sigsetsize = regs.regs[5];
361 if (sigsetsize != sizeof(compat_sigset_t))
364 uset = (compat_sigset_t __user *) regs.regs[4];
365 if (get_sigset(&newset, uset))
367 sigdelsetmask(&newset, ~_BLOCKABLE);
369 spin_lock_irq(¤t->sighand->siglock);
370 current->saved_sigmask = current->blocked;
371 current->blocked = newset;
373 spin_unlock_irq(¤t->sighand->siglock);
375 current->state = TASK_INTERRUPTIBLE;
377 set_thread_flag(TIF_RESTORE_SIGMASK);
378 return -ERESTARTNOHAND;
381 asmlinkage int sys32_sigaction(int sig, const struct sigaction32 __user *act,
382 struct sigaction32 __user *oact)
384 struct k_sigaction new_ka, old_ka;
392 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
394 err |= __get_user(handler, &act->sa_handler);
395 new_ka.sa.sa_handler = (void __user *)(s64)handler;
396 err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
397 err |= __get_user(mask, &act->sa_mask.sig[0]);
401 siginitset(&new_ka.sa.sa_mask, mask);
404 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
407 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
409 err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
410 err |= __put_user((u32)(u64)old_ka.sa.sa_handler,
412 err |= __put_user(old_ka.sa.sa_mask.sig[0], oact->sa_mask.sig);
413 err |= __put_user(0, &oact->sa_mask.sig[1]);
414 err |= __put_user(0, &oact->sa_mask.sig[2]);
415 err |= __put_user(0, &oact->sa_mask.sig[3]);
423 asmlinkage int sys32_sigaltstack(nabi_no_regargs struct pt_regs regs)
425 const stack32_t __user *uss = (const stack32_t __user *) regs.regs[4];
426 stack32_t __user *uoss = (stack32_t __user *) regs.regs[5];
427 unsigned long usp = regs.regs[29];
430 mm_segment_t old_fs = get_fs();
434 if (!access_ok(VERIFY_READ, uss, sizeof(*uss)))
436 err |= __get_user(sp, &uss->ss_sp);
437 kss.ss_sp = (void __user *) (long) sp;
438 err |= __get_user(kss.ss_size, &uss->ss_size);
439 err |= __get_user(kss.ss_flags, &uss->ss_flags);
445 ret = do_sigaltstack(uss ? (stack_t __user *)&kss : NULL,
446 uoss ? (stack_t __user *)&koss : NULL, usp);
450 if (!access_ok(VERIFY_WRITE, uoss, sizeof(*uoss)))
452 sp = (int) (unsigned long) koss.ss_sp;
453 err |= __put_user(sp, &uoss->ss_sp);
454 err |= __put_user(koss.ss_size, &uoss->ss_size);
455 err |= __put_user(koss.ss_flags, &uoss->ss_flags);
462 int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from)
466 if (!access_ok (VERIFY_WRITE, to, sizeof(compat_siginfo_t)))
469 /* If you change siginfo_t structure, please be sure
470 this code is fixed accordingly.
471 It should never copy any pad contained in the structure
472 to avoid security leaks, but must copy the generic
473 3 ints plus the relevant union member.
474 This routine must convert siginfo from 64bit to 32bit as well
476 err = __put_user(from->si_signo, &to->si_signo);
477 err |= __put_user(from->si_errno, &to->si_errno);
478 err |= __put_user((short)from->si_code, &to->si_code);
479 if (from->si_code < 0)
480 err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
482 switch (from->si_code >> 16) {
483 case __SI_TIMER >> 16:
484 err |= __put_user(from->si_tid, &to->si_tid);
485 err |= __put_user(from->si_overrun, &to->si_overrun);
486 err |= __put_user(from->si_int, &to->si_int);
488 case __SI_CHLD >> 16:
489 err |= __put_user(from->si_utime, &to->si_utime);
490 err |= __put_user(from->si_stime, &to->si_stime);
491 err |= __put_user(from->si_status, &to->si_status);
493 err |= __put_user(from->si_pid, &to->si_pid);
494 err |= __put_user(from->si_uid, &to->si_uid);
496 case __SI_FAULT >> 16:
497 err |= __put_user((unsigned long)from->si_addr, &to->si_addr);
499 case __SI_POLL >> 16:
500 err |= __put_user(from->si_band, &to->si_band);
501 err |= __put_user(from->si_fd, &to->si_fd);
503 case __SI_RT >> 16: /* This is not generated by the kernel as of now. */
504 case __SI_MESGQ >> 16:
505 err |= __put_user(from->si_pid, &to->si_pid);
506 err |= __put_user(from->si_uid, &to->si_uid);
507 err |= __put_user(from->si_int, &to->si_int);
514 asmlinkage void sys32_sigreturn(nabi_no_regargs struct pt_regs regs)
516 struct sigframe32 __user *frame;
519 frame = (struct sigframe32 __user *) regs.regs[29];
520 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
522 if (__copy_conv_sigset_from_user(&blocked, &frame->sf_mask))
525 sigdelsetmask(&blocked, ~_BLOCKABLE);
526 spin_lock_irq(¤t->sighand->siglock);
527 current->blocked = blocked;
529 spin_unlock_irq(¤t->sighand->siglock);
531 if (restore_sigcontext32(®s, &frame->sf_sc))
535 * Don't let your children do this ...
537 __asm__ __volatile__(
545 force_sig(SIGSEGV, current);
548 asmlinkage void sys32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
550 struct rt_sigframe32 __user *frame;
556 frame = (struct rt_sigframe32 __user *) regs.regs[29];
557 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
559 if (__copy_conv_sigset_from_user(&set, &frame->rs_uc.uc_sigmask))
562 sigdelsetmask(&set, ~_BLOCKABLE);
563 spin_lock_irq(¤t->sighand->siglock);
564 current->blocked = set;
566 spin_unlock_irq(¤t->sighand->siglock);
568 if (restore_sigcontext32(®s, &frame->rs_uc.uc_mcontext))
571 /* The ucontext contains a stack32_t, so we must convert! */
572 if (__get_user(sp, &frame->rs_uc.uc_stack.ss_sp))
574 st.ss_sp = (void __user *)(long) sp;
575 if (__get_user(st.ss_size, &frame->rs_uc.uc_stack.ss_size))
577 if (__get_user(st.ss_flags, &frame->rs_uc.uc_stack.ss_flags))
580 /* It is more difficult to avoid calling this function than to
581 call it and ignore errors. */
584 do_sigaltstack((stack_t __user *)&st, NULL, regs.regs[29]);
588 * Don't let your children do this ...
590 __asm__ __volatile__(
598 force_sig(SIGSEGV, current);
601 int setup_frame_32(struct k_sigaction * ka, struct pt_regs *regs,
602 int signr, sigset_t *set)
604 struct sigframe32 __user *frame;
607 frame = get_sigframe(ka, regs, sizeof(*frame));
608 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
611 err |= install_sigtramp(frame->sf_code, __NR_O32_sigreturn);
613 err |= setup_sigcontext32(regs, &frame->sf_sc);
614 err |= __copy_conv_sigset_to_user(&frame->sf_mask, set);
620 * Arguments to signal handler:
623 * a1 = 0 (should be cause)
624 * a2 = pointer to struct sigcontext
626 * $25 and c0_epc point to the signal handler, $29 points to the
629 regs->regs[ 4] = signr;
631 regs->regs[ 6] = (unsigned long) &frame->sf_sc;
632 regs->regs[29] = (unsigned long) frame;
633 regs->regs[31] = (unsigned long) frame->sf_code;
634 regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler;
636 DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n",
637 current->comm, current->pid,
638 frame, regs->cp0_epc, regs->regs[31]);
643 force_sigsegv(signr, current);
647 int setup_rt_frame_32(struct k_sigaction * ka, struct pt_regs *regs,
648 int signr, sigset_t *set, siginfo_t *info)
650 struct rt_sigframe32 __user *frame;
654 frame = get_sigframe(ka, regs, sizeof(*frame));
655 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
658 err |= install_sigtramp(frame->rs_code, __NR_O32_rt_sigreturn);
660 /* Convert (siginfo_t -> compat_siginfo_t) and copy to user. */
661 err |= copy_siginfo_to_user32(&frame->rs_info, info);
663 /* Create the ucontext. */
664 err |= __put_user(0, &frame->rs_uc.uc_flags);
665 err |= __put_user(0, &frame->rs_uc.uc_link);
666 sp = (int) (long) current->sas_ss_sp;
667 err |= __put_user(sp,
668 &frame->rs_uc.uc_stack.ss_sp);
669 err |= __put_user(sas_ss_flags(regs->regs[29]),
670 &frame->rs_uc.uc_stack.ss_flags);
671 err |= __put_user(current->sas_ss_size,
672 &frame->rs_uc.uc_stack.ss_size);
673 err |= setup_sigcontext32(regs, &frame->rs_uc.uc_mcontext);
674 err |= __copy_conv_sigset_to_user(&frame->rs_uc.uc_sigmask, set);
680 * Arguments to signal handler:
683 * a1 = 0 (should be cause)
684 * a2 = pointer to ucontext
686 * $25 and c0_epc point to the signal handler, $29 points to
687 * the struct rt_sigframe32.
689 regs->regs[ 4] = signr;
690 regs->regs[ 5] = (unsigned long) &frame->rs_info;
691 regs->regs[ 6] = (unsigned long) &frame->rs_uc;
692 regs->regs[29] = (unsigned long) frame;
693 regs->regs[31] = (unsigned long) frame->rs_code;
694 regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler;
696 DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n",
697 current->comm, current->pid,
698 frame, regs->cp0_epc, regs->regs[31]);
703 force_sigsegv(signr, current);
707 static inline int handle_signal(unsigned long sig, siginfo_t *info,
708 struct k_sigaction *ka, sigset_t *oldset, struct pt_regs * regs)
712 switch (regs->regs[0]) {
713 case ERESTART_RESTARTBLOCK:
715 regs->regs[2] = EINTR;
718 if (!(ka->sa.sa_flags & SA_RESTART)) {
719 regs->regs[2] = EINTR;
723 case ERESTARTNOINTR: /* Userland will reload $v0. */
724 regs->regs[7] = regs->regs[26];
728 regs->regs[0] = 0; /* Don't deal with this again. */
730 if (ka->sa.sa_flags & SA_SIGINFO)
731 ret = current->thread.abi->setup_rt_frame(ka, regs, sig, oldset, info);
733 ret = current->thread.abi->setup_frame(ka, regs, sig, oldset);
735 spin_lock_irq(¤t->sighand->siglock);
736 sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask);
737 if (!(ka->sa.sa_flags & SA_NODEFER))
738 sigaddset(¤t->blocked,sig);
740 spin_unlock_irq(¤t->sighand->siglock);
745 void do_signal32(struct pt_regs *regs)
747 struct k_sigaction ka;
753 * We want the common case to go fast, which is why we may in certain
754 * cases get here from kernel mode. Just return without doing anything
757 if (!user_mode(regs))
760 if (test_thread_flag(TIF_RESTORE_SIGMASK))
761 oldset = ¤t->saved_sigmask;
763 oldset = ¤t->blocked;
765 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
767 /* Whee! Actually deliver the signal. */
768 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
770 * A signal was successfully delivered; the saved
771 * sigmask will have been stored in the signal frame,
772 * and will be restored by sigreturn, so we can simply
773 * clear the TIF_RESTORE_SIGMASK flag.
775 if (test_thread_flag(TIF_RESTORE_SIGMASK))
776 clear_thread_flag(TIF_RESTORE_SIGMASK);
783 * Who's code doesn't conform to the restartable syscall convention
784 * dies here!!! The li instruction, a single machine instruction,
785 * must directly be followed by the syscall instruction.
788 if (regs->regs[2] == ERESTARTNOHAND ||
789 regs->regs[2] == ERESTARTSYS ||
790 regs->regs[2] == ERESTARTNOINTR) {
791 regs->regs[7] = regs->regs[26];
794 if (regs->regs[2] == ERESTART_RESTARTBLOCK) {
795 regs->regs[2] = __NR_O32_restart_syscall;
796 regs->regs[7] = regs->regs[26];
799 regs->regs[0] = 0; /* Don't deal with this again. */
803 * If there's no signal to deliver, we just put the saved sigmask
806 if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
807 clear_thread_flag(TIF_RESTORE_SIGMASK);
808 sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL);
812 asmlinkage int sys32_rt_sigaction(int sig, const struct sigaction32 __user *act,
813 struct sigaction32 __user *oact,
814 unsigned int sigsetsize)
816 struct k_sigaction new_sa, old_sa;
819 /* XXX: Don't preclude handling different sized sigset_t's. */
820 if (sigsetsize != sizeof(sigset_t))
827 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
829 err |= __get_user(handler, &act->sa_handler);
830 new_sa.sa.sa_handler = (void __user *)(s64)handler;
831 err |= __get_user(new_sa.sa.sa_flags, &act->sa_flags);
832 err |= get_sigset(&new_sa.sa.sa_mask, &act->sa_mask);
837 ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa : NULL);
842 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
845 err |= __put_user((u32)(u64)old_sa.sa.sa_handler,
847 err |= __put_user(old_sa.sa.sa_flags, &oact->sa_flags);
848 err |= put_sigset(&old_sa.sa.sa_mask, &oact->sa_mask);
856 asmlinkage int sys32_rt_sigprocmask(int how, compat_sigset_t __user *set,
857 compat_sigset_t __user *oset, unsigned int sigsetsize)
859 sigset_t old_set, new_set;
861 mm_segment_t old_fs = get_fs();
863 if (set && get_sigset(&new_set, set))
867 ret = sys_rt_sigprocmask(how, set ? (sigset_t __user *)&new_set : NULL,
868 oset ? (sigset_t __user *)&old_set : NULL,
872 if (!ret && oset && put_sigset(&old_set, oset))
878 asmlinkage int sys32_rt_sigpending(compat_sigset_t __user *uset,
879 unsigned int sigsetsize)
883 mm_segment_t old_fs = get_fs();
886 ret = sys_rt_sigpending((sigset_t __user *)&set, sigsetsize);
889 if (!ret && put_sigset(&set, uset))
895 asmlinkage int sys32_rt_sigqueueinfo(int pid, int sig, compat_siginfo_t __user *uinfo)
899 mm_segment_t old_fs = get_fs();
901 if (copy_from_user (&info, uinfo, 3*sizeof(int)) ||
902 copy_from_user (info._sifields._pad, uinfo->_sifields._pad, SI_PAD_SIZE))
905 ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
911 sys32_waitid(int which, compat_pid_t pid,
912 compat_siginfo_t __user *uinfo, int options,
913 struct compat_rusage __user *uru)
918 mm_segment_t old_fs = get_fs();
922 ret = sys_waitid(which, pid, (siginfo_t __user *) &info, options,
923 uru ? (struct rusage __user *) &ru : NULL);
926 if (ret < 0 || info.si_signo == 0)
929 if (uru && (ret = put_compat_rusage(&ru, uru)))
932 BUG_ON(info.si_code & __SI_MASK);
933 info.si_code |= __SI_CHLD;
934 return copy_siginfo_to_user32(uinfo, &info);