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 Ralf Baechle
8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
10 #include <linux/sched.h>
12 #include <linux/smp.h>
13 #include <linux/smp_lock.h>
14 #include <linux/kernel.h>
15 #include <linux/signal.h>
16 #include <linux/syscalls.h>
17 #include <linux/errno.h>
18 #include <linux/wait.h>
19 #include <linux/ptrace.h>
20 #include <linux/compat.h>
21 #include <linux/suspend.h>
22 #include <linux/compiler.h>
25 #include <linux/bitops.h>
26 #include <asm/cacheflush.h>
28 #include <asm/uaccess.h>
29 #include <asm/ucontext.h>
30 #include <asm/system.h>
33 #define SI_PAD_SIZE32 ((SI_MAX_SIZE/sizeof(int)) - 3)
35 typedef union sigval32 {
40 typedef struct siginfo32 {
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 */
88 /* POSIX.1b signals */
90 compat_pid_t _pid; /* sender's pid */
91 compat_uid_t _uid; /* sender's uid */
99 * Including <asm/unistd.h> would give use the 64-bit syscall numbers ...
101 #define __NR_O32_sigreturn 4119
102 #define __NR_O32_rt_sigreturn 4193
103 #define __NR_O32_restart_syscall 4253
107 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
109 extern asmlinkage int do_signal32(sigset_t *oldset, struct pt_regs *regs);
111 /* 32-bit compatibility types */
113 #define _NSIG_BPW32 32
114 #define _NSIG_WORDS32 (_NSIG / _NSIG_BPW32)
117 unsigned int sig[_NSIG_WORDS32];
120 typedef unsigned int __sighandler32_t;
121 typedef void (*vfptr_t)(void);
124 unsigned int sa_flags;
125 __sighandler32_t sa_handler;
126 compat_sigset_t sa_mask;
129 /* IRIX compatible stack_t */
130 typedef struct sigaltstack32 {
132 compat_size_t ss_size;
140 struct sigcontext32 uc_mcontext;
141 sigset_t32 uc_sigmask; /* mask last for extensibility */
144 extern void __put_sigset_unknown_nsig(void);
145 extern void __get_sigset_unknown_nsig(void);
147 static inline int put_sigset(const sigset_t *kbuf, compat_sigset_t *ubuf)
151 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(*ubuf)))
154 switch (_NSIG_WORDS) {
156 __put_sigset_unknown_nsig();
158 err |= __put_user (kbuf->sig[1] >> 32, &ubuf->sig[3]);
159 err |= __put_user (kbuf->sig[1] & 0xffffffff, &ubuf->sig[2]);
161 err |= __put_user (kbuf->sig[0] >> 32, &ubuf->sig[1]);
162 err |= __put_user (kbuf->sig[0] & 0xffffffff, &ubuf->sig[0]);
168 static inline int get_sigset(sigset_t *kbuf, const compat_sigset_t *ubuf)
171 unsigned long sig[4];
173 if (!access_ok(VERIFY_READ, ubuf, sizeof(*ubuf)))
176 switch (_NSIG_WORDS) {
178 __get_sigset_unknown_nsig();
180 err |= __get_user (sig[3], &ubuf->sig[3]);
181 err |= __get_user (sig[2], &ubuf->sig[2]);
182 kbuf->sig[1] = sig[2] | (sig[3] << 32);
184 err |= __get_user (sig[1], &ubuf->sig[1]);
185 err |= __get_user (sig[0], &ubuf->sig[0]);
186 kbuf->sig[0] = sig[0] | (sig[1] << 32);
193 * Atomically swap in the new signal mask, and wait for a signal.
195 save_static_function(sys32_sigsuspend);
196 __attribute_used__ noinline static int
197 _sys32_sigsuspend(nabi_no_regargs struct pt_regs regs)
199 compat_sigset_t *uset;
200 sigset_t newset, saveset;
202 uset = (compat_sigset_t *) regs.regs[4];
203 if (get_sigset(&newset, uset))
205 sigdelsetmask(&newset, ~_BLOCKABLE);
207 spin_lock_irq(¤t->sighand->siglock);
208 saveset = current->blocked;
209 current->blocked = newset;
211 spin_unlock_irq(¤t->sighand->siglock);
213 regs.regs[2] = EINTR;
216 current->state = TASK_INTERRUPTIBLE;
218 if (do_signal32(&saveset, ®s))
223 save_static_function(sys32_rt_sigsuspend);
224 __attribute_used__ noinline static int
225 _sys32_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
227 compat_sigset_t *uset;
228 sigset_t newset, saveset;
231 /* XXX Don't preclude handling different sized sigset_t's. */
232 sigsetsize = regs.regs[5];
233 if (sigsetsize != sizeof(compat_sigset_t))
236 uset = (compat_sigset_t *) regs.regs[4];
237 if (get_sigset(&newset, uset))
239 sigdelsetmask(&newset, ~_BLOCKABLE);
241 spin_lock_irq(¤t->sighand->siglock);
242 saveset = current->blocked;
243 current->blocked = newset;
245 spin_unlock_irq(¤t->sighand->siglock);
247 regs.regs[2] = EINTR;
250 current->state = TASK_INTERRUPTIBLE;
252 if (do_signal32(&saveset, ®s))
257 asmlinkage int sys32_sigaction(int sig, const struct sigaction32 *act,
258 struct sigaction32 *oact)
260 struct k_sigaction new_ka, old_ka;
267 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
269 err |= __get_user((u32)(u64)new_ka.sa.sa_handler,
271 err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
272 err |= __get_user(mask, &act->sa_mask.sig[0]);
276 siginitset(&new_ka.sa.sa_mask, mask);
279 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
282 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
284 err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
285 err |= __put_user((u32)(u64)old_ka.sa.sa_handler,
287 err |= __put_user(old_ka.sa.sa_mask.sig[0], oact->sa_mask.sig);
288 err |= __put_user(0, &oact->sa_mask.sig[1]);
289 err |= __put_user(0, &oact->sa_mask.sig[2]);
290 err |= __put_user(0, &oact->sa_mask.sig[3]);
298 asmlinkage int sys32_sigaltstack(nabi_no_regargs struct pt_regs regs)
300 const stack32_t *uss = (const stack32_t *) regs.regs[4];
301 stack32_t *uoss = (stack32_t *) regs.regs[5];
302 unsigned long usp = regs.regs[29];
305 mm_segment_t old_fs = get_fs();
309 if (!access_ok(VERIFY_READ, uss, sizeof(*uss)))
311 err |= __get_user(sp, &uss->ss_sp);
312 kss.ss_sp = (void *) (long) sp;
313 err |= __get_user(kss.ss_size, &uss->ss_size);
314 err |= __get_user(kss.ss_flags, &uss->ss_flags);
320 ret = do_sigaltstack(uss ? &kss : NULL , uoss ? &koss : NULL, usp);
324 if (!access_ok(VERIFY_WRITE, uoss, sizeof(*uoss)))
326 sp = (int) (long) koss.ss_sp;
327 err |= __put_user(sp, &uoss->ss_sp);
328 err |= __put_user(koss.ss_size, &uoss->ss_size);
329 err |= __put_user(koss.ss_flags, &uoss->ss_flags);
336 static asmlinkage int restore_sigcontext32(struct pt_regs *regs,
337 struct sigcontext32 *sc)
341 /* Always make any pending restarted system calls return -EINTR */
342 current_thread_info()->restart_block.fn = do_no_restart_syscall;
344 err |= __get_user(regs->cp0_epc, &sc->sc_pc);
345 err |= __get_user(regs->hi, &sc->sc_mdhi);
346 err |= __get_user(regs->lo, &sc->sc_mdlo);
348 #define restore_gp_reg(i) do { \
349 err |= __get_user(regs->regs[i], &sc->sc_regs[i]); \
351 restore_gp_reg( 1); restore_gp_reg( 2); restore_gp_reg( 3);
352 restore_gp_reg( 4); restore_gp_reg( 5); restore_gp_reg( 6);
353 restore_gp_reg( 7); restore_gp_reg( 8); restore_gp_reg( 9);
354 restore_gp_reg(10); restore_gp_reg(11); restore_gp_reg(12);
355 restore_gp_reg(13); restore_gp_reg(14); restore_gp_reg(15);
356 restore_gp_reg(16); restore_gp_reg(17); restore_gp_reg(18);
357 restore_gp_reg(19); restore_gp_reg(20); restore_gp_reg(21);
358 restore_gp_reg(22); restore_gp_reg(23); restore_gp_reg(24);
359 restore_gp_reg(25); restore_gp_reg(26); restore_gp_reg(27);
360 restore_gp_reg(28); restore_gp_reg(29); restore_gp_reg(30);
362 #undef restore_gp_reg
364 err |= __get_user(current->used_math, &sc->sc_used_math);
368 if (current->used_math) {
369 /* restore fpu context if we have used it before */
371 err |= restore_fp_context32(sc);
373 /* signal handler may have used FPU. Give it up. */
383 u32 sf_ass[4]; /* argument save space for o32 */
384 u32 sf_code[2]; /* signal trampoline */
385 struct sigcontext32 sf_sc;
389 struct rt_sigframe32 {
390 u32 rs_ass[4]; /* argument save space for o32 */
391 u32 rs_code[2]; /* signal trampoline */
392 struct siginfo32 rs_info;
393 struct ucontext32 rs_uc;
396 static int copy_siginfo_to_user32(siginfo_t32 *to, siginfo_t *from)
400 if (!access_ok (VERIFY_WRITE, to, sizeof(siginfo_t32)))
403 /* If you change siginfo_t structure, please be sure
404 this code is fixed accordingly.
405 It should never copy any pad contained in the structure
406 to avoid security leaks, but must copy the generic
407 3 ints plus the relevant union member.
408 This routine must convert siginfo from 64bit to 32bit as well
410 err = __put_user(from->si_signo, &to->si_signo);
411 err |= __put_user(from->si_errno, &to->si_errno);
412 err |= __put_user((short)from->si_code, &to->si_code);
413 if (from->si_code < 0)
414 err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE);
416 switch (from->si_code >> 16) {
417 case __SI_CHLD >> 16:
418 err |= __put_user(from->si_utime, &to->si_utime);
419 err |= __put_user(from->si_stime, &to->si_stime);
420 err |= __put_user(from->si_status, &to->si_status);
422 err |= __put_user(from->si_pid, &to->si_pid);
423 err |= __put_user(from->si_uid, &to->si_uid);
425 case __SI_FAULT >> 16:
426 err |= __put_user((long)from->si_addr, &to->si_addr);
428 case __SI_POLL >> 16:
429 err |= __put_user(from->si_band, &to->si_band);
430 err |= __put_user(from->si_fd, &to->si_fd);
432 case __SI_RT >> 16: /* This is not generated by the kernel as of now. */
433 case __SI_MESGQ >> 16:
434 err |= __put_user(from->si_pid, &to->si_pid);
435 err |= __put_user(from->si_uid, &to->si_uid);
436 err |= __put_user(from->si_int, &to->si_int);
443 asmlinkage void sys32_sigreturn(nabi_no_regargs struct pt_regs regs)
445 struct sigframe *frame;
448 frame = (struct sigframe *) regs.regs[29];
449 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
451 if (__copy_from_user(&blocked, &frame->sf_mask, sizeof(blocked)))
454 sigdelsetmask(&blocked, ~_BLOCKABLE);
455 spin_lock_irq(¤t->sighand->siglock);
456 current->blocked = blocked;
458 spin_unlock_irq(¤t->sighand->siglock);
460 if (restore_sigcontext32(®s, &frame->sf_sc))
464 * Don't let your children do this ...
466 if (current_thread_info()->flags & TIF_SYSCALL_TRACE)
467 do_syscall_trace(®s, 1);
468 __asm__ __volatile__(
476 force_sig(SIGSEGV, current);
479 asmlinkage void sys32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
481 struct rt_sigframe32 *frame;
486 frame = (struct rt_sigframe32 *) regs.regs[29];
487 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
489 if (__copy_from_user(&set, &frame->rs_uc.uc_sigmask, sizeof(set)))
492 sigdelsetmask(&set, ~_BLOCKABLE);
493 spin_lock_irq(¤t->sighand->siglock);
494 current->blocked = set;
496 spin_unlock_irq(¤t->sighand->siglock);
498 if (restore_sigcontext32(®s, &frame->rs_uc.uc_mcontext))
501 /* The ucontext contains a stack32_t, so we must convert! */
502 if (__get_user(sp, &frame->rs_uc.uc_stack.ss_sp))
504 st.ss_size = (long) sp;
505 if (__get_user(st.ss_size, &frame->rs_uc.uc_stack.ss_size))
507 if (__get_user(st.ss_flags, &frame->rs_uc.uc_stack.ss_flags))
510 /* It is more difficult to avoid calling this function than to
511 call it and ignore errors. */
512 do_sigaltstack(&st, NULL, regs.regs[29]);
515 * Don't let your children do this ...
517 __asm__ __volatile__(
525 force_sig(SIGSEGV, current);
528 static inline int setup_sigcontext32(struct pt_regs *regs,
529 struct sigcontext32 *sc)
533 err |= __put_user(regs->cp0_epc, &sc->sc_pc);
534 err |= __put_user(regs->cp0_status, &sc->sc_status);
536 #define save_gp_reg(i) { \
537 err |= __put_user(regs->regs[i], &sc->sc_regs[i]); \
539 __put_user(0, &sc->sc_regs[0]); save_gp_reg(1); save_gp_reg(2);
540 save_gp_reg(3); save_gp_reg(4); save_gp_reg(5); save_gp_reg(6);
541 save_gp_reg(7); save_gp_reg(8); save_gp_reg(9); save_gp_reg(10);
542 save_gp_reg(11); save_gp_reg(12); save_gp_reg(13); save_gp_reg(14);
543 save_gp_reg(15); save_gp_reg(16); save_gp_reg(17); save_gp_reg(18);
544 save_gp_reg(19); save_gp_reg(20); save_gp_reg(21); save_gp_reg(22);
545 save_gp_reg(23); save_gp_reg(24); save_gp_reg(25); save_gp_reg(26);
546 save_gp_reg(27); save_gp_reg(28); save_gp_reg(29); save_gp_reg(30);
550 err |= __put_user(regs->hi, &sc->sc_mdhi);
551 err |= __put_user(regs->lo, &sc->sc_mdlo);
552 err |= __put_user(regs->cp0_cause, &sc->sc_cause);
553 err |= __put_user(regs->cp0_badvaddr, &sc->sc_badvaddr);
555 err |= __put_user(current->used_math, &sc->sc_used_math);
557 if (!current->used_math)
561 * Save FPU state to signal context. Signal handler will "inherit"
566 if (!is_fpu_owner()) {
570 err |= save_fp_context32(sc);
579 * Determine which stack to use..
581 static inline void *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
586 /* Default to using normal stack */
590 * FPU emulator may have it's own trampoline active just
591 * above the user stack, 16-bytes before the next lowest
592 * 16 byte boundary. Try to avoid trashing it.
596 /* This is the X/Open sanctioned signal stack switching. */
597 if ((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags (sp) == 0))
598 sp = current->sas_ss_sp + current->sas_ss_size;
600 return (void *)((sp - frame_size) & ALMASK);
603 static inline void setup_frame(struct k_sigaction * ka, struct pt_regs *regs,
604 int signr, sigset_t *set)
606 struct sigframe *frame;
609 frame = get_sigframe(ka, regs, sizeof(*frame));
610 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
614 * Set up the return code ...
616 * li v0, __NR_O32_sigreturn
619 err |= __put_user(0x24020000 + __NR_O32_sigreturn, frame->sf_code + 0);
620 err |= __put_user(0x0000000c , frame->sf_code + 1);
621 flush_cache_sigtramp((unsigned long) frame->sf_code);
623 err |= setup_sigcontext32(regs, &frame->sf_sc);
624 err |= __copy_to_user(&frame->sf_mask, set, sizeof(*set));
629 * Arguments to signal handler:
632 * a1 = 0 (should be cause)
633 * a2 = pointer to struct sigcontext
635 * $25 and c0_epc point to the signal handler, $29 points to the
638 regs->regs[ 4] = signr;
640 regs->regs[ 6] = (unsigned long) &frame->sf_sc;
641 regs->regs[29] = (unsigned long) frame;
642 regs->regs[31] = (unsigned long) frame->sf_code;
643 regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler;
646 printk("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%p\n",
647 current->comm, current->pid,
648 frame, regs->cp0_epc, frame->sf_code);
653 force_sigsegv(signr, current);
656 static inline void setup_rt_frame(struct k_sigaction * ka,
657 struct pt_regs *regs, int signr,
658 sigset_t *set, siginfo_t *info)
660 struct rt_sigframe32 *frame;
664 frame = get_sigframe(ka, regs, sizeof(*frame));
665 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
668 /* Set up to return from userspace. If provided, use a stub already
671 * Set up the return code ...
673 * li v0, __NR_O32_rt_sigreturn
676 err |= __put_user(0x24020000 + __NR_O32_rt_sigreturn, frame->rs_code + 0);
677 err |= __put_user(0x0000000c , frame->rs_code + 1);
678 flush_cache_sigtramp((unsigned long) frame->rs_code);
680 /* Convert (siginfo_t -> siginfo_t32) and copy to user. */
681 err |= copy_siginfo_to_user32(&frame->rs_info, info);
683 /* Create the ucontext. */
684 err |= __put_user(0, &frame->rs_uc.uc_flags);
685 err |= __put_user(0, &frame->rs_uc.uc_link);
686 sp = (int) (long) current->sas_ss_sp;
687 err |= __put_user(sp,
688 &frame->rs_uc.uc_stack.ss_sp);
689 err |= __put_user(sas_ss_flags(regs->regs[29]),
690 &frame->rs_uc.uc_stack.ss_flags);
691 err |= __put_user(current->sas_ss_size,
692 &frame->rs_uc.uc_stack.ss_size);
693 err |= setup_sigcontext32(regs, &frame->rs_uc.uc_mcontext);
694 err |= __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set));
700 * Arguments to signal handler:
703 * a1 = 0 (should be cause)
704 * a2 = pointer to ucontext
706 * $25 and c0_epc point to the signal handler, $29 points to
707 * the struct rt_sigframe32.
709 regs->regs[ 4] = signr;
710 regs->regs[ 5] = (unsigned long) &frame->rs_info;
711 regs->regs[ 6] = (unsigned long) &frame->rs_uc;
712 regs->regs[29] = (unsigned long) frame;
713 regs->regs[31] = (unsigned long) frame->rs_code;
714 regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler;
717 printk("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%p\n",
718 current->comm, current->pid,
719 frame, regs->cp0_epc, frame->rs_code);
724 force_sigsegv(signr, current);
727 static inline void handle_signal(unsigned long sig, siginfo_t *info,
728 struct k_sigaction *ka, sigset_t *oldset, struct pt_regs * regs)
730 switch (regs->regs[0]) {
731 case ERESTART_RESTARTBLOCK:
733 regs->regs[2] = EINTR;
736 if(!(ka->sa.sa_flags & SA_RESTART)) {
737 regs->regs[2] = EINTR;
741 case ERESTARTNOINTR: /* Userland will reload $v0. */
742 regs->regs[7] = regs->regs[26];
746 regs->regs[0] = 0; /* Don't deal with this again. */
748 if (ka->sa.sa_flags & SA_SIGINFO)
749 setup_rt_frame(ka, regs, sig, oldset, info);
751 setup_frame(ka, regs, sig, oldset);
753 if (!(ka->sa.sa_flags & SA_NODEFER)) {
754 spin_lock_irq(¤t->sighand->siglock);
755 sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask);
756 sigaddset(¤t->blocked,sig);
758 spin_unlock_irq(¤t->sighand->siglock);
762 asmlinkage int do_signal32(sigset_t *oldset, struct pt_regs *regs)
764 struct k_sigaction ka;
769 * We want the common case to go fast, which is why we may in certain
770 * cases get here from kernel mode. Just return without doing anything
773 if (!user_mode(regs))
776 if (current->flags & PF_FREEZE) {
782 oldset = ¤t->blocked;
784 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
786 handle_signal(signr, &info, &ka, oldset, regs);
792 * Who's code doesn't conform to the restartable syscall convention
793 * dies here!!! The li instruction, a single machine instruction,
794 * must directly be followed by the syscall instruction.
797 if (regs->regs[2] == ERESTARTNOHAND ||
798 regs->regs[2] == ERESTARTSYS ||
799 regs->regs[2] == ERESTARTNOINTR) {
800 regs->regs[7] = regs->regs[26];
803 if (regs->regs[2] == ERESTART_RESTARTBLOCK) {
804 regs->regs[2] = __NR_O32_restart_syscall;
805 regs->regs[7] = regs->regs[26];
812 asmlinkage int sys32_rt_sigaction(int sig, const struct sigaction32 *act,
813 struct sigaction32 *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))
826 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
828 err |= __get_user((u32)(u64)new_sa.sa.sa_handler,
830 err |= __get_user(new_sa.sa.sa_flags, &act->sa_flags);
831 err |= get_sigset(&new_sa.sa.sa_mask, &act->sa_mask);
836 ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa : NULL);
841 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
844 err |= __put_user((u32)(u64)old_sa.sa.sa_handler,
846 err |= __put_user(old_sa.sa.sa_flags, &oact->sa_flags);
847 err |= put_sigset(&old_sa.sa.sa_mask, &oact->sa_mask);
855 asmlinkage int sys32_rt_sigprocmask(int how, compat_sigset_t *set,
856 compat_sigset_t *oset, unsigned int sigsetsize)
858 sigset_t old_set, new_set;
860 mm_segment_t old_fs = get_fs();
862 if (set && get_sigset(&new_set, set))
866 ret = sys_rt_sigprocmask(how, set ? &new_set : NULL,
867 oset ? &old_set : NULL, sigsetsize);
870 if (!ret && oset && put_sigset(&old_set, oset))
876 asmlinkage int sys32_rt_sigpending(compat_sigset_t *uset,
877 unsigned int sigsetsize)
881 mm_segment_t old_fs = get_fs();
884 ret = sys_rt_sigpending(&set, sigsetsize);
887 if (!ret && put_sigset(&set, uset))
893 asmlinkage int sys32_rt_sigtimedwait(compat_sigset_t *uthese,
894 siginfo_t32 *uinfo, struct compat_timespec *uts,
895 compat_time_t sigsetsize)
899 compat_sigset_t these32;
905 * As the result of a brainfarting competition a few years ago the
906 * size of sigset_t for the 32-bit kernel was choosen to be 128 bits
907 * but nothing so far is actually using that many, 64 are enough. So
908 * for now we just drop the high bits.
910 if (copy_from_user (&these32, uthese, sizeof(compat_old_sigset_t)))
913 switch (_NSIG_WORDS) {
915 case 4: these.sig[3] = these32.sig[6] | (((long)these32.sig[7]) << 32);
916 case 3: these.sig[2] = these32.sig[4] | (((long)these32.sig[5]) << 32);
917 case 2: these.sig[1] = these32.sig[2] | (((long)these32.sig[3]) << 32);
918 case 1: these.sig[0] = these32.sig[0] | (((long)these32.sig[1]) << 32);
921 case 4: these.sig[3] = these32.sig[7] | (((long)these32.sig[6]) << 32);
922 case 3: these.sig[2] = these32.sig[5] | (((long)these32.sig[4]) << 32);
923 case 2: these.sig[1] = these32.sig[3] | (((long)these32.sig[2]) << 32);
924 case 1: these.sig[0] = these32.sig[1] | (((long)these32.sig[0]) << 32);
929 * Invert the set of allowed signals to get those we
932 sigdelsetmask(&these, sigmask(SIGKILL)|sigmask(SIGSTOP));
936 if (get_user (ts.tv_sec, &uts->tv_sec) ||
937 get_user (ts.tv_nsec, &uts->tv_nsec))
939 if (ts.tv_nsec >= 1000000000L || ts.tv_nsec < 0
944 spin_lock_irq(¤t->sighand->siglock);
945 sig = dequeue_signal(current, &these, &info);
947 /* None ready -- temporarily unblock those we're interested
948 in so that we'll be awakened when they arrive. */
949 sigset_t oldblocked = current->blocked;
950 sigandsets(¤t->blocked, ¤t->blocked, &these);
952 spin_unlock_irq(¤t->sighand->siglock);
954 timeout = MAX_SCHEDULE_TIMEOUT;
956 timeout = (timespec_to_jiffies(&ts)
957 + (ts.tv_sec || ts.tv_nsec));
959 current->state = TASK_INTERRUPTIBLE;
960 timeout = schedule_timeout(timeout);
962 spin_lock_irq(¤t->sighand->siglock);
963 sig = dequeue_signal(current, &these, &info);
964 current->blocked = oldblocked;
967 spin_unlock_irq(¤t->sighand->siglock);
972 if (copy_siginfo_to_user32(uinfo, &info))
984 asmlinkage int sys32_rt_sigqueueinfo(int pid, int sig, siginfo_t32 *uinfo)
988 mm_segment_t old_fs = get_fs();
990 if (copy_from_user (&info, uinfo, 3*sizeof(int)) ||
991 copy_from_user (info._sifields._pad, uinfo->_sifields._pad, SI_PAD_SIZE))
994 ret = sys_rt_sigqueueinfo(pid, sig, &info);