2 * Copyright (C) 1991, 1992 Linus Torvalds
3 * Copyright (C) 2000, 2001, 2002 Andi Kleen SuSE Labs
5 * 1997-11-28 Modified for POSIX.1b signals by Richard Henderson
6 * 2000-06-20 Pentium III FXSR, SSE support by Gareth Hughes
7 * 2000-2002 x86-64 support by Andi Kleen
10 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
12 #include <linux/sched.h>
14 #include <linux/smp.h>
15 #include <linux/kernel.h>
16 #include <linux/errno.h>
17 #include <linux/wait.h>
18 #include <linux/tracehook.h>
19 #include <linux/unistd.h>
20 #include <linux/stddef.h>
21 #include <linux/personality.h>
22 #include <linux/uaccess.h>
23 #include <linux/user-return-notifier.h>
24 #include <linux/uprobes.h>
25 #include <linux/context_tracking.h>
27 #include <asm/processor.h>
28 #include <asm/ucontext.h>
29 #include <asm/fpu/internal.h>
30 #include <asm/fpu/signal.h>
33 #include <asm/sighandling.h>
37 #include <asm/proto.h>
38 #include <asm/ia32_unistd.h>
39 #endif /* CONFIG_X86_64 */
41 #include <asm/syscall.h>
42 #include <asm/syscalls.h>
44 #include <asm/sigframe.h>
45 #include <asm/signal.h>
47 #define COPY(x) do { \
48 get_user_ex(regs->x, &sc->x); \
51 #define GET_SEG(seg) ({ \
53 get_user_ex(tmp, &sc->seg); \
57 #define COPY_SEG(seg) do { \
58 regs->seg = GET_SEG(seg); \
61 #define COPY_SEG_CPL3(seg) do { \
62 regs->seg = GET_SEG(seg) | 3; \
67 * If regs->ss will cause an IRET fault, change it. Otherwise leave it
68 * alone. Using this generally makes no sense unless
69 * user_64bit_mode(regs) would return true.
71 static void force_valid_ss(struct pt_regs *regs)
74 asm volatile ("lar %[old_ss], %[ar]\n\t"
75 "jz 1f\n\t" /* If invalid: */
76 "xorl %[ar], %[ar]\n\t" /* set ar = 0 */
79 : [old_ss] "rm" ((u16)regs->ss));
82 * For a valid 64-bit user context, we need DPL 3, type
83 * read-write data or read-write exp-down data, and S and P
84 * set. We can't use VERW because VERW doesn't check the
87 ar &= AR_DPL_MASK | AR_S | AR_P | AR_TYPE_MASK;
88 if (ar != (AR_DPL3 | AR_S | AR_P | AR_TYPE_RWDATA) &&
89 ar != (AR_DPL3 | AR_S | AR_P | AR_TYPE_RWDATA_EXPDOWN))
94 static int restore_sigcontext(struct pt_regs *regs,
95 struct sigcontext __user *sc,
96 unsigned long uc_flags)
98 unsigned long buf_val;
100 unsigned int tmpflags;
101 unsigned int err = 0;
103 /* Always make any pending restarted system calls return -EINTR */
104 current->restart_block.fn = do_no_restart_syscall;
109 set_user_gs(regs, GET_SEG(gs));
113 #endif /* CONFIG_X86_32 */
115 COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx);
116 COPY(dx); COPY(cx); COPY(ip); COPY(ax);
127 #endif /* CONFIG_X86_64 */
134 * Fix up SS if needed for the benefit of old DOSEMU and
137 if (unlikely(!(uc_flags & UC_STRICT_RESTORE_SS) &&
138 user_64bit_mode(regs)))
139 force_valid_ss(regs);
142 get_user_ex(tmpflags, &sc->flags);
143 regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
144 regs->orig_ax = -1; /* disable syscall checks */
146 get_user_ex(buf_val, &sc->fpstate);
147 buf = (void __user *)buf_val;
148 } get_user_catch(err);
150 err |= fpu__restore_sig(buf, IS_ENABLED(CONFIG_X86_32));
157 int setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
158 struct pt_regs *regs, unsigned long mask)
165 put_user_ex(get_user_gs(regs), (unsigned int __user *)&sc->gs);
166 put_user_ex(regs->fs, (unsigned int __user *)&sc->fs);
167 put_user_ex(regs->es, (unsigned int __user *)&sc->es);
168 put_user_ex(regs->ds, (unsigned int __user *)&sc->ds);
169 #endif /* CONFIG_X86_32 */
171 put_user_ex(regs->di, &sc->di);
172 put_user_ex(regs->si, &sc->si);
173 put_user_ex(regs->bp, &sc->bp);
174 put_user_ex(regs->sp, &sc->sp);
175 put_user_ex(regs->bx, &sc->bx);
176 put_user_ex(regs->dx, &sc->dx);
177 put_user_ex(regs->cx, &sc->cx);
178 put_user_ex(regs->ax, &sc->ax);
180 put_user_ex(regs->r8, &sc->r8);
181 put_user_ex(regs->r9, &sc->r9);
182 put_user_ex(regs->r10, &sc->r10);
183 put_user_ex(regs->r11, &sc->r11);
184 put_user_ex(regs->r12, &sc->r12);
185 put_user_ex(regs->r13, &sc->r13);
186 put_user_ex(regs->r14, &sc->r14);
187 put_user_ex(regs->r15, &sc->r15);
188 #endif /* CONFIG_X86_64 */
190 put_user_ex(current->thread.trap_nr, &sc->trapno);
191 put_user_ex(current->thread.error_code, &sc->err);
192 put_user_ex(regs->ip, &sc->ip);
194 put_user_ex(regs->cs, (unsigned int __user *)&sc->cs);
195 put_user_ex(regs->flags, &sc->flags);
196 put_user_ex(regs->sp, &sc->sp_at_signal);
197 put_user_ex(regs->ss, (unsigned int __user *)&sc->ss);
198 #else /* !CONFIG_X86_32 */
199 put_user_ex(regs->flags, &sc->flags);
200 put_user_ex(regs->cs, &sc->cs);
201 put_user_ex(0, &sc->gs);
202 put_user_ex(0, &sc->fs);
203 put_user_ex(regs->ss, &sc->ss);
204 #endif /* CONFIG_X86_32 */
206 put_user_ex(fpstate, &sc->fpstate);
208 /* non-iBCS2 extensions.. */
209 put_user_ex(mask, &sc->oldmask);
210 put_user_ex(current->thread.cr2, &sc->cr2);
211 } put_user_catch(err);
217 * Set up a signal frame.
221 * Determine which stack to use..
223 static unsigned long align_sigframe(unsigned long sp)
227 * Align the stack pointer according to the i386 ABI,
228 * i.e. so that on function entry ((sp + 4) & 15) == 0.
230 sp = ((sp + 4) & -16ul) - 4;
231 #else /* !CONFIG_X86_32 */
232 sp = round_down(sp, 16) - 8;
238 get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
239 void __user **fpstate)
241 /* Default to using normal stack */
242 unsigned long math_size = 0;
243 unsigned long sp = regs->sp;
244 unsigned long buf_fx = 0;
245 int onsigstack = on_sig_stack(sp);
246 struct fpu *fpu = ¤t->thread.fpu;
249 if (IS_ENABLED(CONFIG_X86_64))
252 /* This is the X/Open sanctioned signal stack switching. */
253 if (ka->sa.sa_flags & SA_ONSTACK) {
254 if (sas_ss_flags(sp) == 0)
255 sp = current->sas_ss_sp + current->sas_ss_size;
256 } else if (IS_ENABLED(CONFIG_X86_32) &&
258 (regs->ss & 0xffff) != __USER_DS &&
259 !(ka->sa.sa_flags & SA_RESTORER) &&
260 ka->sa.sa_restorer) {
261 /* This is the legacy signal stack switching. */
262 sp = (unsigned long) ka->sa.sa_restorer;
265 if (fpu->fpstate_active) {
266 sp = fpu__alloc_mathframe(sp, IS_ENABLED(CONFIG_X86_32),
267 &buf_fx, &math_size);
268 *fpstate = (void __user *)sp;
271 sp = align_sigframe(sp - frame_size);
274 * If we are on the alternate signal stack and would overflow it, don't.
275 * Return an always-bogus address instead so we will die with SIGSEGV.
277 if (onsigstack && !likely(on_sig_stack(sp)))
278 return (void __user *)-1L;
280 /* save i387 and extended state */
281 if (fpu->fpstate_active &&
282 copy_fpstate_to_sigframe(*fpstate, (void __user *)buf_fx, math_size) < 0)
283 return (void __user *)-1L;
285 return (void __user *)sp;
289 static const struct {
293 } __attribute__((packed)) retcode = {
294 0xb858, /* popl %eax; movl $..., %eax */
296 0x80cd, /* int $0x80 */
299 static const struct {
304 } __attribute__((packed)) rt_retcode = {
305 0xb8, /* movl $..., %eax */
307 0x80cd, /* int $0x80 */
312 __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
313 struct pt_regs *regs)
315 struct sigframe __user *frame;
316 void __user *restorer;
318 void __user *fpstate = NULL;
320 frame = get_sigframe(&ksig->ka, regs, sizeof(*frame), &fpstate);
322 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
325 if (__put_user(sig, &frame->sig))
328 if (setup_sigcontext(&frame->sc, fpstate, regs, set->sig[0]))
331 if (_NSIG_WORDS > 1) {
332 if (__copy_to_user(&frame->extramask, &set->sig[1],
333 sizeof(frame->extramask)))
337 if (current->mm->context.vdso)
338 restorer = current->mm->context.vdso +
339 vdso_image_32.sym___kernel_sigreturn;
341 restorer = &frame->retcode;
342 if (ksig->ka.sa.sa_flags & SA_RESTORER)
343 restorer = ksig->ka.sa.sa_restorer;
345 /* Set up to return from userspace. */
346 err |= __put_user(restorer, &frame->pretcode);
349 * This is popl %eax ; movl $__NR_sigreturn, %eax ; int $0x80
351 * WE DO NOT USE IT ANY MORE! It's only left here for historical
352 * reasons and because gdb uses it as a signature to notice
353 * signal handler stack frames.
355 err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
360 /* Set up registers for signal handler */
361 regs->sp = (unsigned long)frame;
362 regs->ip = (unsigned long)ksig->ka.sa.sa_handler;
363 regs->ax = (unsigned long)sig;
367 regs->ds = __USER_DS;
368 regs->es = __USER_DS;
369 regs->ss = __USER_DS;
370 regs->cs = __USER_CS;
375 static int __setup_rt_frame(int sig, struct ksignal *ksig,
376 sigset_t *set, struct pt_regs *regs)
378 struct rt_sigframe __user *frame;
379 void __user *restorer;
381 void __user *fpstate = NULL;
383 frame = get_sigframe(&ksig->ka, regs, sizeof(*frame), &fpstate);
385 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
389 put_user_ex(sig, &frame->sig);
390 put_user_ex(&frame->info, &frame->pinfo);
391 put_user_ex(&frame->uc, &frame->puc);
393 /* Create the ucontext. */
394 if (boot_cpu_has(X86_FEATURE_XSAVE))
395 put_user_ex(UC_FP_XSTATE, &frame->uc.uc_flags);
397 put_user_ex(0, &frame->uc.uc_flags);
398 put_user_ex(0, &frame->uc.uc_link);
399 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
401 /* Set up to return from userspace. */
402 restorer = current->mm->context.vdso +
403 vdso_image_32.sym___kernel_rt_sigreturn;
404 if (ksig->ka.sa.sa_flags & SA_RESTORER)
405 restorer = ksig->ka.sa.sa_restorer;
406 put_user_ex(restorer, &frame->pretcode);
409 * This is movl $__NR_rt_sigreturn, %ax ; int $0x80
411 * WE DO NOT USE IT ANY MORE! It's only left here for historical
412 * reasons and because gdb uses it as a signature to notice
413 * signal handler stack frames.
415 put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
416 } put_user_catch(err);
418 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
419 err |= setup_sigcontext(&frame->uc.uc_mcontext, fpstate,
421 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
426 /* Set up registers for signal handler */
427 regs->sp = (unsigned long)frame;
428 regs->ip = (unsigned long)ksig->ka.sa.sa_handler;
429 regs->ax = (unsigned long)sig;
430 regs->dx = (unsigned long)&frame->info;
431 regs->cx = (unsigned long)&frame->uc;
433 regs->ds = __USER_DS;
434 regs->es = __USER_DS;
435 regs->ss = __USER_DS;
436 regs->cs = __USER_CS;
440 #else /* !CONFIG_X86_32 */
441 static unsigned long frame_uc_flags(struct pt_regs *regs)
445 if (boot_cpu_has(X86_FEATURE_XSAVE))
446 flags = UC_FP_XSTATE | UC_SIGCONTEXT_SS;
448 flags = UC_SIGCONTEXT_SS;
450 if (likely(user_64bit_mode(regs)))
451 flags |= UC_STRICT_RESTORE_SS;
456 static int __setup_rt_frame(int sig, struct ksignal *ksig,
457 sigset_t *set, struct pt_regs *regs)
459 struct rt_sigframe __user *frame;
460 void __user *fp = NULL;
463 frame = get_sigframe(&ksig->ka, regs, sizeof(struct rt_sigframe), &fp);
465 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
468 if (ksig->ka.sa.sa_flags & SA_SIGINFO) {
469 if (copy_siginfo_to_user(&frame->info, &ksig->info))
474 /* Create the ucontext. */
475 put_user_ex(frame_uc_flags(regs), &frame->uc.uc_flags);
476 put_user_ex(0, &frame->uc.uc_link);
477 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
479 /* Set up to return from userspace. If provided, use a stub
480 already in userspace. */
481 /* x86-64 should always use SA_RESTORER. */
482 if (ksig->ka.sa.sa_flags & SA_RESTORER) {
483 put_user_ex(ksig->ka.sa.sa_restorer, &frame->pretcode);
485 /* could use a vstub here */
488 } put_user_catch(err);
490 err |= setup_sigcontext(&frame->uc.uc_mcontext, fp, regs, set->sig[0]);
491 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
496 /* Set up registers for signal handler */
498 /* In case the signal handler was declared without prototypes */
501 /* This also works for non SA_SIGINFO handlers because they expect the
502 next argument after the signal number on the stack. */
503 regs->si = (unsigned long)&frame->info;
504 regs->dx = (unsigned long)&frame->uc;
505 regs->ip = (unsigned long) ksig->ka.sa.sa_handler;
507 regs->sp = (unsigned long)frame;
510 * Set up the CS and SS registers to run signal handlers in
511 * 64-bit mode, even if the handler happens to be interrupting
512 * 32-bit or 16-bit code.
514 * SS is subtle. In 64-bit mode, we don't need any particular
515 * SS descriptor, but we do need SS to be valid. It's possible
516 * that the old SS is entirely bogus -- this can happen if the
517 * signal we're trying to deliver is #GP or #SS caused by a bad
518 * SS value. We also have a compatbility issue here: DOSEMU
519 * relies on the contents of the SS register indicating the
520 * SS value at the time of the signal, even though that code in
521 * DOSEMU predates sigreturn's ability to restore SS. (DOSEMU
522 * avoids relying on sigreturn to restore SS; instead it uses
523 * a trampoline.) So we do our best: if the old SS was valid,
524 * we keep it. Otherwise we replace it.
526 regs->cs = __USER_CS;
528 if (unlikely(regs->ss != __USER_DS))
529 force_valid_ss(regs);
533 #endif /* CONFIG_X86_32 */
535 static int x32_setup_rt_frame(struct ksignal *ksig,
536 compat_sigset_t *set,
537 struct pt_regs *regs)
539 #ifdef CONFIG_X86_X32_ABI
540 struct rt_sigframe_x32 __user *frame;
541 void __user *restorer;
543 void __user *fpstate = NULL;
545 frame = get_sigframe(&ksig->ka, regs, sizeof(*frame), &fpstate);
547 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
550 if (ksig->ka.sa.sa_flags & SA_SIGINFO) {
551 if (__copy_siginfo_to_user32(&frame->info, &ksig->info, true))
556 /* Create the ucontext. */
557 put_user_ex(frame_uc_flags(regs), &frame->uc.uc_flags);
558 put_user_ex(0, &frame->uc.uc_link);
559 compat_save_altstack_ex(&frame->uc.uc_stack, regs->sp);
560 put_user_ex(0, &frame->uc.uc__pad0);
562 if (ksig->ka.sa.sa_flags & SA_RESTORER) {
563 restorer = ksig->ka.sa.sa_restorer;
565 /* could use a vstub here */
569 put_user_ex(restorer, &frame->pretcode);
570 } put_user_catch(err);
572 err |= setup_sigcontext(&frame->uc.uc_mcontext, fpstate,
574 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
579 /* Set up registers for signal handler */
580 regs->sp = (unsigned long) frame;
581 regs->ip = (unsigned long) ksig->ka.sa.sa_handler;
583 /* We use the x32 calling convention here... */
584 regs->di = ksig->sig;
585 regs->si = (unsigned long) &frame->info;
586 regs->dx = (unsigned long) &frame->uc;
588 loadsegment(ds, __USER_DS);
589 loadsegment(es, __USER_DS);
591 regs->cs = __USER_CS;
592 regs->ss = __USER_DS;
593 #endif /* CONFIG_X86_X32_ABI */
599 * Do a signal return; undo the signal stack.
602 asmlinkage unsigned long sys_sigreturn(void)
604 struct pt_regs *regs = current_pt_regs();
605 struct sigframe __user *frame;
608 frame = (struct sigframe __user *)(regs->sp - 8);
610 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
612 if (__get_user(set.sig[0], &frame->sc.oldmask) || (_NSIG_WORDS > 1
613 && __copy_from_user(&set.sig[1], &frame->extramask,
614 sizeof(frame->extramask))))
617 set_current_blocked(&set);
620 * x86_32 has no uc_flags bits relevant to restore_sigcontext.
621 * Save a few cycles by skipping the __get_user.
623 if (restore_sigcontext(regs, &frame->sc, 0))
628 signal_fault(regs, frame, "sigreturn");
632 #endif /* CONFIG_X86_32 */
634 asmlinkage long sys_rt_sigreturn(void)
636 struct pt_regs *regs = current_pt_regs();
637 struct rt_sigframe __user *frame;
639 unsigned long uc_flags;
641 frame = (struct rt_sigframe __user *)(regs->sp - sizeof(long));
642 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
644 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
646 if (__get_user(uc_flags, &frame->uc.uc_flags))
649 set_current_blocked(&set);
651 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, uc_flags))
654 if (restore_altstack(&frame->uc.uc_stack))
660 signal_fault(regs, frame, "rt_sigreturn");
664 static inline int is_ia32_compat_frame(struct ksignal *ksig)
666 return IS_ENABLED(CONFIG_IA32_EMULATION) &&
667 ksig->ka.sa.sa_flags & SA_IA32_ABI;
670 static inline int is_ia32_frame(struct ksignal *ksig)
672 return IS_ENABLED(CONFIG_X86_32) || is_ia32_compat_frame(ksig);
675 static inline int is_x32_frame(struct ksignal *ksig)
677 return IS_ENABLED(CONFIG_X86_X32_ABI) &&
678 ksig->ka.sa.sa_flags & SA_X32_ABI;
682 setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
684 int usig = ksig->sig;
685 sigset_t *set = sigmask_to_save();
686 compat_sigset_t *cset = (compat_sigset_t *) set;
688 /* Set up the stack frame */
689 if (is_ia32_frame(ksig)) {
690 if (ksig->ka.sa.sa_flags & SA_SIGINFO)
691 return ia32_setup_rt_frame(usig, ksig, cset, regs);
693 return ia32_setup_frame(usig, ksig, cset, regs);
694 } else if (is_x32_frame(ksig)) {
695 return x32_setup_rt_frame(ksig, cset, regs);
697 return __setup_rt_frame(ksig->sig, ksig, set, regs);
702 handle_signal(struct ksignal *ksig, struct pt_regs *regs)
704 bool stepping, failed;
705 struct fpu *fpu = ¤t->thread.fpu;
707 if (v8086_mode(regs))
708 save_v86_state((struct kernel_vm86_regs *) regs, VM86_SIGNAL);
710 /* Are we from a system call? */
711 if (syscall_get_nr(current, regs) >= 0) {
712 /* If so, check system call restarting.. */
713 switch (syscall_get_error(current, regs)) {
714 case -ERESTART_RESTARTBLOCK:
715 case -ERESTARTNOHAND:
720 if (!(ksig->ka.sa.sa_flags & SA_RESTART)) {
725 case -ERESTARTNOINTR:
726 regs->ax = regs->orig_ax;
733 * If TF is set due to a debugger (TIF_FORCED_TF), clear TF now
734 * so that register information in the sigcontext is correct and
735 * then notify the tracer before entering the signal handler.
737 stepping = test_thread_flag(TIF_SINGLESTEP);
739 user_disable_single_step(current);
741 failed = (setup_rt_frame(ksig, regs) < 0);
744 * Clear the direction flag as per the ABI for function entry.
746 * Clear RF when entering the signal handler, because
747 * it might disable possible debug exception from the
750 * Clear TF for the case when it wasn't set by debugger to
751 * avoid the recursive send_sigtrap() in SIGTRAP handler.
753 regs->flags &= ~(X86_EFLAGS_DF|X86_EFLAGS_RF|X86_EFLAGS_TF);
755 * Ensure the signal handler starts with the new fpu state.
757 if (fpu->fpstate_active)
760 signal_setup_done(failed, ksig, stepping);
763 static inline unsigned long get_nr_restart_syscall(const struct pt_regs *regs)
766 * This function is fundamentally broken as currently
769 * The idea is that we want to trigger a call to the
770 * restart_block() syscall and that we want in_ia32_syscall(),
771 * in_x32_syscall(), etc. to match whatever they were in the
772 * syscall being restarted. We assume that the syscall
773 * instruction at (regs->ip - 2) matches whatever syscall
774 * instruction we used to enter in the first place.
776 * The problem is that we can get here when ptrace pokes
777 * syscall-like values into regs even if we're not in a syscall
780 * For now, we maintain historical behavior and guess based on
781 * stored state. We could do better by saving the actual
782 * syscall arch in restart_block or (with caveats on x32) by
783 * checking if regs->ip points to 'int $0x80'. The current
784 * behavior is incorrect if a tracer has a different bitness
787 #ifdef CONFIG_IA32_EMULATION
788 if (current->thread.status & (TS_COMPAT|TS_I386_REGS_POKED))
789 return __NR_ia32_restart_syscall;
791 #ifdef CONFIG_X86_X32_ABI
792 return __NR_restart_syscall | (regs->orig_ax & __X32_SYSCALL_BIT);
794 return __NR_restart_syscall;
799 * Note that 'init' is a special process: it doesn't get signals it doesn't
800 * want to handle. Thus you cannot kill init even with a SIGKILL even by
803 void do_signal(struct pt_regs *regs)
807 if (get_signal(&ksig)) {
808 /* Whee! Actually deliver the signal. */
809 handle_signal(&ksig, regs);
813 /* Did we come from a system call? */
814 if (syscall_get_nr(current, regs) >= 0) {
815 /* Restart the system call - no handlers present */
816 switch (syscall_get_error(current, regs)) {
817 case -ERESTARTNOHAND:
819 case -ERESTARTNOINTR:
820 regs->ax = regs->orig_ax;
824 case -ERESTART_RESTARTBLOCK:
825 regs->ax = get_nr_restart_syscall(regs);
832 * If there's no signal to deliver, we just put the saved sigmask
835 restore_saved_sigmask();
838 void signal_fault(struct pt_regs *regs, void __user *frame, char *where)
840 struct task_struct *me = current;
842 if (show_unhandled_signals && printk_ratelimit()) {
844 "%s[%d] bad frame in %s frame:%p ip:%lx sp:%lx orax:%lx",
845 task_pid_nr(current) > 1 ? KERN_INFO : KERN_EMERG,
846 me->comm, me->pid, where, frame,
847 regs->ip, regs->sp, regs->orig_ax);
848 print_vma_addr(" in ", regs->ip);
852 force_sig(SIGSEGV, me);
855 #ifdef CONFIG_X86_X32_ABI
856 asmlinkage long sys32_x32_rt_sigreturn(void)
858 struct pt_regs *regs = current_pt_regs();
859 struct rt_sigframe_x32 __user *frame;
861 unsigned long uc_flags;
863 frame = (struct rt_sigframe_x32 __user *)(regs->sp - 8);
865 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
867 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
869 if (__get_user(uc_flags, &frame->uc.uc_flags))
872 set_current_blocked(&set);
874 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, uc_flags))
877 if (compat_restore_altstack(&frame->uc.uc_stack))
883 signal_fault(regs, frame, "x32 rt_sigreturn");