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/sched.h>
13 #include <linux/smp.h>
14 #include <linux/smp_lock.h>
15 #include <linux/kernel.h>
16 #include <linux/signal.h>
17 #include <linux/syscalls.h>
18 #include <linux/errno.h>
19 #include <linux/wait.h>
20 #include <linux/ptrace.h>
21 #include <linux/compat.h>
22 #include <linux/suspend.h>
23 #include <linux/compiler.h>
27 #include <linux/bitops.h>
28 #include <asm/cacheflush.h>
30 #include <asm/uaccess.h>
31 #include <asm/ucontext.h>
32 #include <asm/system.h>
36 #include "signal-common.h"
38 #define SI_PAD_SIZE32 ((SI_MAX_SIZE/sizeof(int)) - 3)
40 typedef struct compat_siginfo {
46 int _pad[SI_PAD_SIZE32];
50 compat_pid_t _pid; /* sender's pid */
51 compat_uid_t _uid; /* sender's uid */
56 compat_pid_t _pid; /* which child */
57 compat_uid_t _uid; /* sender's uid */
58 int _status; /* exit code */
59 compat_clock_t _utime;
60 compat_clock_t _stime;
65 compat_pid_t _pid; /* which child */
66 compat_clock_t _utime;
67 int _status; /* exit code */
68 compat_clock_t _stime;
71 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
73 s32 _addr; /* faulting insn/memory ref. */
76 /* SIGPOLL, SIGXFSZ (To do ...) */
78 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
84 timer_t _tid; /* timer id */
85 int _overrun; /* overrun count */
86 compat_sigval_t _sigval;/* same as below */
87 int _sys_private; /* not to be passed to user */
90 /* POSIX.1b signals */
92 compat_pid_t _pid; /* sender's pid */
93 compat_uid_t _uid; /* sender's uid */
94 compat_sigval_t _sigval;
101 * Including <asm/unistd.h> would give use the 64-bit syscall numbers ...
103 #define __NR_O32_sigreturn 4119
104 #define __NR_O32_rt_sigreturn 4193
105 #define __NR_O32_restart_syscall 4253
107 /* 32-bit compatibility types */
109 #define _NSIG_BPW32 32
110 #define _NSIG_WORDS32 (_NSIG / _NSIG_BPW32)
113 unsigned int sig[_NSIG_WORDS32];
116 typedef unsigned int __sighandler32_t;
117 typedef void (*vfptr_t)(void);
120 unsigned int sa_flags;
121 __sighandler32_t sa_handler;
122 compat_sigset_t sa_mask;
125 /* IRIX compatible stack_t */
126 typedef struct sigaltstack32 {
128 compat_size_t ss_size;
136 struct sigcontext32 uc_mcontext;
137 sigset_t32 uc_sigmask; /* mask last for extensibility */
141 * Horribly complicated - with the bloody RM9000 workarounds enabled
142 * the signal trampolines is moving to the end of the structure so we can
143 * increase the alignment without breaking software compatibility.
145 #if ICACHE_REFILLS_WORKAROUND_WAR == 0
148 u32 sf_ass[4]; /* argument save space for o32 */
149 u32 sf_code[2]; /* signal trampoline */
150 struct sigcontext32 sf_sc;
154 struct rt_sigframe32 {
155 u32 rs_ass[4]; /* argument save space for o32 */
156 u32 rs_code[2]; /* signal trampoline */
157 compat_siginfo_t rs_info;
158 struct ucontext32 rs_uc;
161 #else /* ICACHE_REFILLS_WORKAROUND_WAR */
164 u32 sf_ass[4]; /* argument save space for o32 */
166 struct sigcontext32 sf_sc; /* hw context */
168 u32 sf_code[8] ____cacheline_aligned; /* signal trampoline */
171 struct rt_sigframe32 {
172 u32 rs_ass[4]; /* argument save space for o32 */
174 compat_siginfo_t rs_info;
175 struct ucontext32 rs_uc;
176 u32 rs_code[8] __attribute__((aligned(32))); /* signal trampoline */
179 #endif /* !ICACHE_REFILLS_WORKAROUND_WAR */
182 * sigcontext handlers
184 static int setup_sigcontext32(struct pt_regs *regs,
185 struct sigcontext32 __user *sc)
190 err |= __put_user(regs->cp0_epc, &sc->sc_pc);
192 err |= __put_user(0, &sc->sc_regs[0]);
193 for (i = 1; i < 32; i++)
194 err |= __put_user(regs->regs[i], &sc->sc_regs[i]);
196 err |= __put_user(regs->hi, &sc->sc_mdhi);
197 err |= __put_user(regs->lo, &sc->sc_mdlo);
199 err |= __put_user(rddsp(DSP_MASK), &sc->sc_dsp);
200 err |= __put_user(mfhi1(), &sc->sc_hi1);
201 err |= __put_user(mflo1(), &sc->sc_lo1);
202 err |= __put_user(mfhi2(), &sc->sc_hi2);
203 err |= __put_user(mflo2(), &sc->sc_lo2);
204 err |= __put_user(mfhi3(), &sc->sc_hi3);
205 err |= __put_user(mflo3(), &sc->sc_lo3);
208 err |= __put_user(!!used_math(), &sc->sc_used_math);
212 * Save FPU state to signal context. Signal handler
213 * will "inherit" current FPU state.
217 if (!is_fpu_owner()) {
221 err |= save_fp_context32(sc);
228 static int restore_sigcontext32(struct pt_regs *regs,
229 struct sigcontext32 __user *sc)
236 /* Always make any pending restarted system calls return -EINTR */
237 current_thread_info()->restart_block.fn = do_no_restart_syscall;
239 err |= __get_user(regs->cp0_epc, &sc->sc_pc);
240 err |= __get_user(regs->hi, &sc->sc_mdhi);
241 err |= __get_user(regs->lo, &sc->sc_mdlo);
243 err |= __get_user(treg, &sc->sc_hi1); mthi1(treg);
244 err |= __get_user(treg, &sc->sc_lo1); mtlo1(treg);
245 err |= __get_user(treg, &sc->sc_hi2); mthi2(treg);
246 err |= __get_user(treg, &sc->sc_lo2); mtlo2(treg);
247 err |= __get_user(treg, &sc->sc_hi3); mthi3(treg);
248 err |= __get_user(treg, &sc->sc_lo3); mtlo3(treg);
249 err |= __get_user(treg, &sc->sc_dsp); wrdsp(treg, DSP_MASK);
252 for (i = 1; i < 32; i++)
253 err |= __get_user(regs->regs[i], &sc->sc_regs[i]);
255 err |= __get_user(used_math, &sc->sc_used_math);
256 conditional_used_math(used_math);
261 /* restore fpu context if we have used it before */
263 err |= restore_fp_context32(sc);
265 /* signal handler may have used FPU. Give it up. */
277 extern void __put_sigset_unknown_nsig(void);
278 extern void __get_sigset_unknown_nsig(void);
280 static inline int put_sigset(const sigset_t *kbuf, compat_sigset_t __user *ubuf)
284 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(*ubuf)))
287 switch (_NSIG_WORDS) {
289 __put_sigset_unknown_nsig();
291 err |= __put_user (kbuf->sig[1] >> 32, &ubuf->sig[3]);
292 err |= __put_user (kbuf->sig[1] & 0xffffffff, &ubuf->sig[2]);
294 err |= __put_user (kbuf->sig[0] >> 32, &ubuf->sig[1]);
295 err |= __put_user (kbuf->sig[0] & 0xffffffff, &ubuf->sig[0]);
301 static inline int get_sigset(sigset_t *kbuf, const compat_sigset_t __user *ubuf)
304 unsigned long sig[4];
306 if (!access_ok(VERIFY_READ, ubuf, sizeof(*ubuf)))
309 switch (_NSIG_WORDS) {
311 __get_sigset_unknown_nsig();
313 err |= __get_user (sig[3], &ubuf->sig[3]);
314 err |= __get_user (sig[2], &ubuf->sig[2]);
315 kbuf->sig[1] = sig[2] | (sig[3] << 32);
317 err |= __get_user (sig[1], &ubuf->sig[1]);
318 err |= __get_user (sig[0], &ubuf->sig[0]);
319 kbuf->sig[0] = sig[0] | (sig[1] << 32);
326 * Atomically swap in the new signal mask, and wait for a signal.
329 asmlinkage int sys32_sigsuspend(nabi_no_regargs struct pt_regs regs)
331 compat_sigset_t __user *uset;
334 uset = (compat_sigset_t __user *) regs.regs[4];
335 if (get_sigset(&newset, uset))
337 sigdelsetmask(&newset, ~_BLOCKABLE);
339 spin_lock_irq(¤t->sighand->siglock);
340 current->saved_sigmask = current->blocked;
341 current->blocked = newset;
343 spin_unlock_irq(¤t->sighand->siglock);
345 current->state = TASK_INTERRUPTIBLE;
347 set_thread_flag(TIF_RESTORE_SIGMASK);
348 return -ERESTARTNOHAND;
351 asmlinkage int sys32_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
353 compat_sigset_t __user *uset;
357 /* XXX Don't preclude handling different sized sigset_t's. */
358 sigsetsize = regs.regs[5];
359 if (sigsetsize != sizeof(compat_sigset_t))
362 uset = (compat_sigset_t __user *) regs.regs[4];
363 if (get_sigset(&newset, uset))
365 sigdelsetmask(&newset, ~_BLOCKABLE);
367 spin_lock_irq(¤t->sighand->siglock);
368 current->saved_sigmask = current->blocked;
369 current->blocked = newset;
371 spin_unlock_irq(¤t->sighand->siglock);
373 current->state = TASK_INTERRUPTIBLE;
375 set_thread_flag(TIF_RESTORE_SIGMASK);
376 return -ERESTARTNOHAND;
379 asmlinkage int sys32_sigaction(int sig, const struct sigaction32 __user *act,
380 struct sigaction32 __user *oact)
382 struct k_sigaction new_ka, old_ka;
390 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
392 err |= __get_user(handler, &act->sa_handler);
393 new_ka.sa.sa_handler = (void __user *)(s64)handler;
394 err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
395 err |= __get_user(mask, &act->sa_mask.sig[0]);
399 siginitset(&new_ka.sa.sa_mask, mask);
402 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
405 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
407 err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
408 err |= __put_user((u32)(u64)old_ka.sa.sa_handler,
410 err |= __put_user(old_ka.sa.sa_mask.sig[0], oact->sa_mask.sig);
411 err |= __put_user(0, &oact->sa_mask.sig[1]);
412 err |= __put_user(0, &oact->sa_mask.sig[2]);
413 err |= __put_user(0, &oact->sa_mask.sig[3]);
421 asmlinkage int sys32_sigaltstack(nabi_no_regargs struct pt_regs regs)
423 const stack32_t __user *uss = (const stack32_t __user *) regs.regs[4];
424 stack32_t __user *uoss = (stack32_t __user *) regs.regs[5];
425 unsigned long usp = regs.regs[29];
428 mm_segment_t old_fs = get_fs();
432 if (!access_ok(VERIFY_READ, uss, sizeof(*uss)))
434 err |= __get_user(sp, &uss->ss_sp);
435 kss.ss_sp = (void __user *) (long) sp;
436 err |= __get_user(kss.ss_size, &uss->ss_size);
437 err |= __get_user(kss.ss_flags, &uss->ss_flags);
443 ret = do_sigaltstack(uss ? (stack_t __user *)&kss : NULL,
444 uoss ? (stack_t __user *)&koss : NULL, usp);
448 if (!access_ok(VERIFY_WRITE, uoss, sizeof(*uoss)))
450 sp = (int) (unsigned long) koss.ss_sp;
451 err |= __put_user(sp, &uoss->ss_sp);
452 err |= __put_user(koss.ss_size, &uoss->ss_size);
453 err |= __put_user(koss.ss_flags, &uoss->ss_flags);
460 int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from)
464 if (!access_ok (VERIFY_WRITE, to, sizeof(compat_siginfo_t)))
467 /* If you change siginfo_t structure, please be sure
468 this code is fixed accordingly.
469 It should never copy any pad contained in the structure
470 to avoid security leaks, but must copy the generic
471 3 ints plus the relevant union member.
472 This routine must convert siginfo from 64bit to 32bit as well
474 err = __put_user(from->si_signo, &to->si_signo);
475 err |= __put_user(from->si_errno, &to->si_errno);
476 err |= __put_user((short)from->si_code, &to->si_code);
477 if (from->si_code < 0)
478 err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
480 switch (from->si_code >> 16) {
481 case __SI_TIMER >> 16:
482 err |= __put_user(from->si_tid, &to->si_tid);
483 err |= __put_user(from->si_overrun, &to->si_overrun);
484 err |= __put_user(from->si_int, &to->si_int);
486 case __SI_CHLD >> 16:
487 err |= __put_user(from->si_utime, &to->si_utime);
488 err |= __put_user(from->si_stime, &to->si_stime);
489 err |= __put_user(from->si_status, &to->si_status);
491 err |= __put_user(from->si_pid, &to->si_pid);
492 err |= __put_user(from->si_uid, &to->si_uid);
494 case __SI_FAULT >> 16:
495 err |= __put_user((unsigned long)from->si_addr, &to->si_addr);
497 case __SI_POLL >> 16:
498 err |= __put_user(from->si_band, &to->si_band);
499 err |= __put_user(from->si_fd, &to->si_fd);
501 case __SI_RT >> 16: /* This is not generated by the kernel as of now. */
502 case __SI_MESGQ >> 16:
503 err |= __put_user(from->si_pid, &to->si_pid);
504 err |= __put_user(from->si_uid, &to->si_uid);
505 err |= __put_user(from->si_int, &to->si_int);
512 asmlinkage void sys32_sigreturn(nabi_no_regargs struct pt_regs regs)
514 struct sigframe32 __user *frame;
517 frame = (struct sigframe32 __user *) regs.regs[29];
518 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
520 if (__copy_from_user(&blocked, &frame->sf_mask, sizeof(blocked)))
523 sigdelsetmask(&blocked, ~_BLOCKABLE);
524 spin_lock_irq(¤t->sighand->siglock);
525 current->blocked = blocked;
527 spin_unlock_irq(¤t->sighand->siglock);
529 if (restore_sigcontext32(®s, &frame->sf_sc))
533 * Don't let your children do this ...
535 __asm__ __volatile__(
543 force_sig(SIGSEGV, current);
546 asmlinkage void sys32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
548 struct rt_sigframe32 __user *frame;
554 frame = (struct rt_sigframe32 __user *) regs.regs[29];
555 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
557 if (__copy_from_user(&set, &frame->rs_uc.uc_sigmask, sizeof(set)))
560 sigdelsetmask(&set, ~_BLOCKABLE);
561 spin_lock_irq(¤t->sighand->siglock);
562 current->blocked = set;
564 spin_unlock_irq(¤t->sighand->siglock);
566 if (restore_sigcontext32(®s, &frame->rs_uc.uc_mcontext))
569 /* The ucontext contains a stack32_t, so we must convert! */
570 if (__get_user(sp, &frame->rs_uc.uc_stack.ss_sp))
572 st.ss_sp = (void __user *)(long) sp;
573 if (__get_user(st.ss_size, &frame->rs_uc.uc_stack.ss_size))
575 if (__get_user(st.ss_flags, &frame->rs_uc.uc_stack.ss_flags))
578 /* It is more difficult to avoid calling this function than to
579 call it and ignore errors. */
582 do_sigaltstack((stack_t __user *)&st, NULL, regs.regs[29]);
586 * Don't let your children do this ...
588 __asm__ __volatile__(
596 force_sig(SIGSEGV, current);
599 int setup_frame_32(struct k_sigaction * ka, struct pt_regs *regs,
600 int signr, sigset_t *set)
602 struct sigframe32 __user *frame;
605 frame = get_sigframe(ka, regs, sizeof(*frame));
606 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
609 err |= install_sigtramp(frame->sf_code, __NR_O32_sigreturn);
611 err |= setup_sigcontext32(regs, &frame->sf_sc);
612 err |= __copy_to_user(&frame->sf_mask, set, sizeof(*set));
617 * Arguments to signal handler:
620 * a1 = 0 (should be cause)
621 * a2 = pointer to struct sigcontext
623 * $25 and c0_epc point to the signal handler, $29 points to the
626 regs->regs[ 4] = signr;
628 regs->regs[ 6] = (unsigned long) &frame->sf_sc;
629 regs->regs[29] = (unsigned long) frame;
630 regs->regs[31] = (unsigned long) frame->sf_code;
631 regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler;
633 DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n",
634 current->comm, current->pid,
635 frame, regs->cp0_epc, regs->regs[31]);
640 force_sigsegv(signr, current);
644 int setup_rt_frame_32(struct k_sigaction * ka, struct pt_regs *regs,
645 int signr, sigset_t *set, siginfo_t *info)
647 struct rt_sigframe32 __user *frame;
651 frame = get_sigframe(ka, regs, sizeof(*frame));
652 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
655 err |= install_sigtramp(frame->rs_code, __NR_O32_rt_sigreturn);
657 /* Convert (siginfo_t -> compat_siginfo_t) and copy to user. */
658 err |= copy_siginfo_to_user32(&frame->rs_info, info);
660 /* Create the ucontext. */
661 err |= __put_user(0, &frame->rs_uc.uc_flags);
662 err |= __put_user(0, &frame->rs_uc.uc_link);
663 sp = (int) (long) current->sas_ss_sp;
664 err |= __put_user(sp,
665 &frame->rs_uc.uc_stack.ss_sp);
666 err |= __put_user(sas_ss_flags(regs->regs[29]),
667 &frame->rs_uc.uc_stack.ss_flags);
668 err |= __put_user(current->sas_ss_size,
669 &frame->rs_uc.uc_stack.ss_size);
670 err |= setup_sigcontext32(regs, &frame->rs_uc.uc_mcontext);
671 err |= __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set));
677 * Arguments to signal handler:
680 * a1 = 0 (should be cause)
681 * a2 = pointer to ucontext
683 * $25 and c0_epc point to the signal handler, $29 points to
684 * the struct rt_sigframe32.
686 regs->regs[ 4] = signr;
687 regs->regs[ 5] = (unsigned long) &frame->rs_info;
688 regs->regs[ 6] = (unsigned long) &frame->rs_uc;
689 regs->regs[29] = (unsigned long) frame;
690 regs->regs[31] = (unsigned long) frame->rs_code;
691 regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler;
693 DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n",
694 current->comm, current->pid,
695 frame, regs->cp0_epc, regs->regs[31]);
700 force_sigsegv(signr, current);
704 static inline int handle_signal(unsigned long sig, siginfo_t *info,
705 struct k_sigaction *ka, sigset_t *oldset, struct pt_regs * regs)
709 switch (regs->regs[0]) {
710 case ERESTART_RESTARTBLOCK:
712 regs->regs[2] = EINTR;
715 if (!(ka->sa.sa_flags & SA_RESTART)) {
716 regs->regs[2] = EINTR;
720 case ERESTARTNOINTR: /* Userland will reload $v0. */
721 regs->regs[7] = regs->regs[26];
725 regs->regs[0] = 0; /* Don't deal with this again. */
727 if (ka->sa.sa_flags & SA_SIGINFO)
728 ret = current->thread.abi->setup_rt_frame(ka, regs, sig, oldset, info);
730 ret = current->thread.abi->setup_frame(ka, regs, sig, oldset);
732 spin_lock_irq(¤t->sighand->siglock);
733 sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask);
734 if (!(ka->sa.sa_flags & SA_NODEFER))
735 sigaddset(¤t->blocked,sig);
737 spin_unlock_irq(¤t->sighand->siglock);
742 void do_signal32(struct pt_regs *regs)
744 struct k_sigaction ka;
750 * We want the common case to go fast, which is why we may in certain
751 * cases get here from kernel mode. Just return without doing anything
754 if (!user_mode(regs))
757 if (test_thread_flag(TIF_RESTORE_SIGMASK))
758 oldset = ¤t->saved_sigmask;
760 oldset = ¤t->blocked;
762 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
764 /* Whee! Actually deliver the signal. */
765 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
767 * A signal was successfully delivered; the saved
768 * sigmask will have been stored in the signal frame,
769 * and will be restored by sigreturn, so we can simply
770 * clear the TIF_RESTORE_SIGMASK flag.
772 if (test_thread_flag(TIF_RESTORE_SIGMASK))
773 clear_thread_flag(TIF_RESTORE_SIGMASK);
780 * Who's code doesn't conform to the restartable syscall convention
781 * dies here!!! The li instruction, a single machine instruction,
782 * must directly be followed by the syscall instruction.
785 if (regs->regs[2] == ERESTARTNOHAND ||
786 regs->regs[2] == ERESTARTSYS ||
787 regs->regs[2] == ERESTARTNOINTR) {
788 regs->regs[7] = regs->regs[26];
791 if (regs->regs[2] == ERESTART_RESTARTBLOCK) {
792 regs->regs[2] = __NR_O32_restart_syscall;
793 regs->regs[7] = regs->regs[26];
796 regs->regs[0] = 0; /* Don't deal with this again. */
800 * If there's no signal to deliver, we just put the saved sigmask
803 if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
804 clear_thread_flag(TIF_RESTORE_SIGMASK);
805 sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL);
809 asmlinkage int sys32_rt_sigaction(int sig, const struct sigaction32 __user *act,
810 struct sigaction32 __user *oact,
811 unsigned int sigsetsize)
813 struct k_sigaction new_sa, old_sa;
816 /* XXX: Don't preclude handling different sized sigset_t's. */
817 if (sigsetsize != sizeof(sigset_t))
824 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
826 err |= __get_user(handler, &act->sa_handler);
827 new_sa.sa.sa_handler = (void __user *)(s64)handler;
828 err |= __get_user(new_sa.sa.sa_flags, &act->sa_flags);
829 err |= get_sigset(&new_sa.sa.sa_mask, &act->sa_mask);
834 ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa : NULL);
839 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
842 err |= __put_user((u32)(u64)old_sa.sa.sa_handler,
844 err |= __put_user(old_sa.sa.sa_flags, &oact->sa_flags);
845 err |= put_sigset(&old_sa.sa.sa_mask, &oact->sa_mask);
853 asmlinkage int sys32_rt_sigprocmask(int how, compat_sigset_t __user *set,
854 compat_sigset_t __user *oset, unsigned int sigsetsize)
856 sigset_t old_set, new_set;
858 mm_segment_t old_fs = get_fs();
860 if (set && get_sigset(&new_set, set))
864 ret = sys_rt_sigprocmask(how, set ? (sigset_t __user *)&new_set : NULL,
865 oset ? (sigset_t __user *)&old_set : NULL,
869 if (!ret && oset && put_sigset(&old_set, oset))
875 asmlinkage int sys32_rt_sigpending(compat_sigset_t __user *uset,
876 unsigned int sigsetsize)
880 mm_segment_t old_fs = get_fs();
883 ret = sys_rt_sigpending((sigset_t __user *)&set, sigsetsize);
886 if (!ret && put_sigset(&set, uset))
892 asmlinkage int sys32_rt_sigqueueinfo(int pid, int sig, compat_siginfo_t __user *uinfo)
896 mm_segment_t old_fs = get_fs();
898 if (copy_from_user (&info, uinfo, 3*sizeof(int)) ||
899 copy_from_user (info._sifields._pad, uinfo->_sifields._pad, SI_PAD_SIZE))
902 ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
908 sys32_waitid(int which, compat_pid_t pid,
909 compat_siginfo_t __user *uinfo, int options,
910 struct compat_rusage __user *uru)
915 mm_segment_t old_fs = get_fs();
919 ret = sys_waitid(which, pid, (siginfo_t __user *) &info, options,
920 uru ? (struct rusage __user *) &ru : NULL);
923 if (ret < 0 || info.si_signo == 0)
926 if (uru && (ret = put_compat_rusage(&ru, uru)))
929 BUG_ON(info.si_code & __SI_MASK);
930 info.si_code |= __SI_CHLD;
931 return copy_siginfo_to_user32(uinfo, &info);