1
2
3
4
5
6
7
8
9#include <linux/sched.h>
10#include <linux/mm.h>
11#include <linux/smp.h>
12#include <linux/kernel.h>
13#include <linux/signal.h>
14#include <linux/errno.h>
15#include <linux/wait.h>
16#include <linux/ptrace.h>
17#include <linux/tracehook.h>
18#include <linux/unistd.h>
19#include <linux/stddef.h>
20#include <linux/personality.h>
21#include <linux/uaccess.h>
22#include <linux/user-return-notifier.h>
23
24#include <asm/processor.h>
25#include <asm/ucontext.h>
26#include <asm/i387.h>
27#include <asm/vdso.h>
28#include <asm/mce.h>
29
30#ifdef CONFIG_X86_64
31#include <asm/proto.h>
32#include <asm/ia32_unistd.h>
33#endif
34
35#include <asm/syscall.h>
36#include <asm/syscalls.h>
37
38#include <asm/sigframe.h>
39
40#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
41
42#define __FIX_EFLAGS (X86_EFLAGS_AC | X86_EFLAGS_OF | \
43 X86_EFLAGS_DF | X86_EFLAGS_TF | X86_EFLAGS_SF | \
44 X86_EFLAGS_ZF | X86_EFLAGS_AF | X86_EFLAGS_PF | \
45 X86_EFLAGS_CF)
46
47#ifdef CONFIG_X86_32
48# define FIX_EFLAGS (__FIX_EFLAGS | X86_EFLAGS_RF)
49#else
50# define FIX_EFLAGS __FIX_EFLAGS
51#endif
52
53#define COPY(x) do { \
54 get_user_ex(regs->x, &sc->x); \
55} while (0)
56
57#define GET_SEG(seg) ({ \
58 unsigned short tmp; \
59 get_user_ex(tmp, &sc->seg); \
60 tmp; \
61})
62
63#define COPY_SEG(seg) do { \
64 regs->seg = GET_SEG(seg); \
65} while (0)
66
67#define COPY_SEG_CPL3(seg) do { \
68 regs->seg = GET_SEG(seg) | 3; \
69} while (0)
70
71static int
72restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc,
73 unsigned long *pax)
74{
75 void __user *buf;
76 unsigned int tmpflags;
77 unsigned int err = 0;
78
79
80 current_thread_info()->restart_block.fn = do_no_restart_syscall;
81
82 get_user_try {
83
84#ifdef CONFIG_X86_32
85 set_user_gs(regs, GET_SEG(gs));
86 COPY_SEG(fs);
87 COPY_SEG(es);
88 COPY_SEG(ds);
89#endif
90
91 COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx);
92 COPY(dx); COPY(cx); COPY(ip);
93
94#ifdef CONFIG_X86_64
95 COPY(r8);
96 COPY(r9);
97 COPY(r10);
98 COPY(r11);
99 COPY(r12);
100 COPY(r13);
101 COPY(r14);
102 COPY(r15);
103#endif
104
105#ifdef CONFIG_X86_32
106 COPY_SEG_CPL3(cs);
107 COPY_SEG_CPL3(ss);
108#else
109
110
111
112 COPY_SEG_CPL3(cs);
113#endif
114
115 get_user_ex(tmpflags, &sc->flags);
116 regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
117 regs->orig_ax = -1;
118
119 get_user_ex(buf, &sc->fpstate);
120 err |= restore_i387_xstate(buf);
121
122 get_user_ex(*pax, &sc->ax);
123 } get_user_catch(err);
124
125 return err;
126}
127
128static int
129setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
130 struct pt_regs *regs, unsigned long mask)
131{
132 int err = 0;
133
134 put_user_try {
135
136#ifdef CONFIG_X86_32
137 put_user_ex(get_user_gs(regs), (unsigned int __user *)&sc->gs);
138 put_user_ex(regs->fs, (unsigned int __user *)&sc->fs);
139 put_user_ex(regs->es, (unsigned int __user *)&sc->es);
140 put_user_ex(regs->ds, (unsigned int __user *)&sc->ds);
141#endif
142
143 put_user_ex(regs->di, &sc->di);
144 put_user_ex(regs->si, &sc->si);
145 put_user_ex(regs->bp, &sc->bp);
146 put_user_ex(regs->sp, &sc->sp);
147 put_user_ex(regs->bx, &sc->bx);
148 put_user_ex(regs->dx, &sc->dx);
149 put_user_ex(regs->cx, &sc->cx);
150 put_user_ex(regs->ax, &sc->ax);
151#ifdef CONFIG_X86_64
152 put_user_ex(regs->r8, &sc->r8);
153 put_user_ex(regs->r9, &sc->r9);
154 put_user_ex(regs->r10, &sc->r10);
155 put_user_ex(regs->r11, &sc->r11);
156 put_user_ex(regs->r12, &sc->r12);
157 put_user_ex(regs->r13, &sc->r13);
158 put_user_ex(regs->r14, &sc->r14);
159 put_user_ex(regs->r15, &sc->r15);
160#endif
161
162 put_user_ex(current->thread.trap_no, &sc->trapno);
163 put_user_ex(current->thread.error_code, &sc->err);
164 put_user_ex(regs->ip, &sc->ip);
165#ifdef CONFIG_X86_32
166 put_user_ex(regs->cs, (unsigned int __user *)&sc->cs);
167 put_user_ex(regs->flags, &sc->flags);
168 put_user_ex(regs->sp, &sc->sp_at_signal);
169 put_user_ex(regs->ss, (unsigned int __user *)&sc->ss);
170#else
171 put_user_ex(regs->flags, &sc->flags);
172 put_user_ex(regs->cs, &sc->cs);
173 put_user_ex(0, &sc->gs);
174 put_user_ex(0, &sc->fs);
175#endif
176
177 put_user_ex(fpstate, &sc->fpstate);
178
179
180 put_user_ex(mask, &sc->oldmask);
181 put_user_ex(current->thread.cr2, &sc->cr2);
182 } put_user_catch(err);
183
184 return err;
185}
186
187
188
189
190
191
192
193
194static unsigned long align_sigframe(unsigned long sp)
195{
196#ifdef CONFIG_X86_32
197
198
199
200
201 sp = ((sp + 4) & -16ul) - 4;
202#else
203 sp = round_down(sp, 16) - 8;
204#endif
205 return sp;
206}
207
208static inline void __user *
209get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
210 void __user **fpstate)
211{
212
213 unsigned long sp = regs->sp;
214 int onsigstack = on_sig_stack(sp);
215
216#ifdef CONFIG_X86_64
217
218 sp -= 128;
219#endif
220
221 if (!onsigstack) {
222
223 if (ka->sa.sa_flags & SA_ONSTACK) {
224 if (current->sas_ss_size)
225 sp = current->sas_ss_sp + current->sas_ss_size;
226 } else {
227#ifdef CONFIG_X86_32
228
229 if ((regs->ss & 0xffff) != __USER_DS &&
230 !(ka->sa.sa_flags & SA_RESTORER) &&
231 ka->sa.sa_restorer)
232 sp = (unsigned long) ka->sa.sa_restorer;
233#endif
234 }
235 }
236
237 if (used_math()) {
238 sp -= sig_xstate_size;
239#ifdef CONFIG_X86_64
240 sp = round_down(sp, 64);
241#endif
242 *fpstate = (void __user *)sp;
243 }
244
245 sp = align_sigframe(sp - frame_size);
246
247
248
249
250
251 if (onsigstack && !likely(on_sig_stack(sp)))
252 return (void __user *)-1L;
253
254
255 if (used_math() && save_i387_xstate(*fpstate) < 0)
256 return (void __user *)-1L;
257
258 return (void __user *)sp;
259}
260
261#ifdef CONFIG_X86_32
262static const struct {
263 u16 poplmovl;
264 u32 val;
265 u16 int80;
266} __attribute__((packed)) retcode = {
267 0xb858,
268 __NR_sigreturn,
269 0x80cd,
270};
271
272static const struct {
273 u8 movl;
274 u32 val;
275 u16 int80;
276 u8 pad;
277} __attribute__((packed)) rt_retcode = {
278 0xb8,
279 __NR_rt_sigreturn,
280 0x80cd,
281 0
282};
283
284static int
285__setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
286 struct pt_regs *regs)
287{
288 struct sigframe __user *frame;
289 void __user *restorer;
290 int err = 0;
291 void __user *fpstate = NULL;
292
293 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
294
295 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
296 return -EFAULT;
297
298 if (__put_user(sig, &frame->sig))
299 return -EFAULT;
300
301 if (setup_sigcontext(&frame->sc, fpstate, regs, set->sig[0]))
302 return -EFAULT;
303
304 if (_NSIG_WORDS > 1) {
305 if (__copy_to_user(&frame->extramask, &set->sig[1],
306 sizeof(frame->extramask)))
307 return -EFAULT;
308 }
309
310 if (current->mm->context.vdso)
311 restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
312 else
313 restorer = &frame->retcode;
314 if (ka->sa.sa_flags & SA_RESTORER)
315 restorer = ka->sa.sa_restorer;
316
317
318 err |= __put_user(restorer, &frame->pretcode);
319
320
321
322
323
324
325
326
327 err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
328
329 if (err)
330 return -EFAULT;
331
332
333 regs->sp = (unsigned long)frame;
334 regs->ip = (unsigned long)ka->sa.sa_handler;
335 regs->ax = (unsigned long)sig;
336 regs->dx = 0;
337 regs->cx = 0;
338
339 regs->ds = __USER_DS;
340 regs->es = __USER_DS;
341 regs->ss = __USER_DS;
342 regs->cs = __USER_CS;
343
344 return 0;
345}
346
347static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
348 sigset_t *set, struct pt_regs *regs)
349{
350 struct rt_sigframe __user *frame;
351 void __user *restorer;
352 int err = 0;
353 void __user *fpstate = NULL;
354
355 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
356
357 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
358 return -EFAULT;
359
360 put_user_try {
361 put_user_ex(sig, &frame->sig);
362 put_user_ex(&frame->info, &frame->pinfo);
363 put_user_ex(&frame->uc, &frame->puc);
364 err |= copy_siginfo_to_user(&frame->info, info);
365
366
367 if (cpu_has_xsave)
368 put_user_ex(UC_FP_XSTATE, &frame->uc.uc_flags);
369 else
370 put_user_ex(0, &frame->uc.uc_flags);
371 put_user_ex(0, &frame->uc.uc_link);
372 put_user_ex(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
373 put_user_ex(sas_ss_flags(regs->sp),
374 &frame->uc.uc_stack.ss_flags);
375 put_user_ex(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
376 err |= setup_sigcontext(&frame->uc.uc_mcontext, fpstate,
377 regs, set->sig[0]);
378 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
379
380
381 restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
382 if (ka->sa.sa_flags & SA_RESTORER)
383 restorer = ka->sa.sa_restorer;
384 put_user_ex(restorer, &frame->pretcode);
385
386
387
388
389
390
391
392
393 put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
394 } put_user_catch(err);
395
396 if (err)
397 return -EFAULT;
398
399
400 regs->sp = (unsigned long)frame;
401 regs->ip = (unsigned long)ka->sa.sa_handler;
402 regs->ax = (unsigned long)sig;
403 regs->dx = (unsigned long)&frame->info;
404 regs->cx = (unsigned long)&frame->uc;
405
406 regs->ds = __USER_DS;
407 regs->es = __USER_DS;
408 regs->ss = __USER_DS;
409 regs->cs = __USER_CS;
410
411 return 0;
412}
413#else
414static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
415 sigset_t *set, struct pt_regs *regs)
416{
417 struct rt_sigframe __user *frame;
418 void __user *fp = NULL;
419 int err = 0;
420 struct task_struct *me = current;
421
422 frame = get_sigframe(ka, regs, sizeof(struct rt_sigframe), &fp);
423
424 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
425 return -EFAULT;
426
427 if (ka->sa.sa_flags & SA_SIGINFO) {
428 if (copy_siginfo_to_user(&frame->info, info))
429 return -EFAULT;
430 }
431
432 put_user_try {
433
434 if (cpu_has_xsave)
435 put_user_ex(UC_FP_XSTATE, &frame->uc.uc_flags);
436 else
437 put_user_ex(0, &frame->uc.uc_flags);
438 put_user_ex(0, &frame->uc.uc_link);
439 put_user_ex(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
440 put_user_ex(sas_ss_flags(regs->sp),
441 &frame->uc.uc_stack.ss_flags);
442 put_user_ex(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
443 err |= setup_sigcontext(&frame->uc.uc_mcontext, fp, regs, set->sig[0]);
444 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
445
446
447
448
449 if (ka->sa.sa_flags & SA_RESTORER) {
450 put_user_ex(ka->sa.sa_restorer, &frame->pretcode);
451 } else {
452
453 err |= -EFAULT;
454 }
455 } put_user_catch(err);
456
457 if (err)
458 return -EFAULT;
459
460
461 regs->di = sig;
462
463 regs->ax = 0;
464
465
466
467 regs->si = (unsigned long)&frame->info;
468 regs->dx = (unsigned long)&frame->uc;
469 regs->ip = (unsigned long) ka->sa.sa_handler;
470
471 regs->sp = (unsigned long)frame;
472
473
474
475 regs->cs = __USER_CS;
476
477 return 0;
478}
479#endif
480
481#ifdef CONFIG_X86_32
482
483
484
485asmlinkage int
486sys_sigsuspend(int history0, int history1, old_sigset_t mask)
487{
488 mask &= _BLOCKABLE;
489 spin_lock_irq(¤t->sighand->siglock);
490 current->saved_sigmask = current->blocked;
491 siginitset(¤t->blocked, mask);
492 recalc_sigpending();
493 spin_unlock_irq(¤t->sighand->siglock);
494
495 current->state = TASK_INTERRUPTIBLE;
496 schedule();
497 set_restore_sigmask();
498
499 return -ERESTARTNOHAND;
500}
501
502asmlinkage int
503sys_sigaction(int sig, const struct old_sigaction __user *act,
504 struct old_sigaction __user *oact)
505{
506 struct k_sigaction new_ka, old_ka;
507 int ret = 0;
508
509 if (act) {
510 old_sigset_t mask;
511
512 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
513 return -EFAULT;
514
515 get_user_try {
516 get_user_ex(new_ka.sa.sa_handler, &act->sa_handler);
517 get_user_ex(new_ka.sa.sa_flags, &act->sa_flags);
518 get_user_ex(mask, &act->sa_mask);
519 get_user_ex(new_ka.sa.sa_restorer, &act->sa_restorer);
520 } get_user_catch(ret);
521
522 if (ret)
523 return -EFAULT;
524 siginitset(&new_ka.sa.sa_mask, mask);
525 }
526
527 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
528
529 if (!ret && oact) {
530 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
531 return -EFAULT;
532
533 put_user_try {
534 put_user_ex(old_ka.sa.sa_handler, &oact->sa_handler);
535 put_user_ex(old_ka.sa.sa_flags, &oact->sa_flags);
536 put_user_ex(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
537 put_user_ex(old_ka.sa.sa_restorer, &oact->sa_restorer);
538 } put_user_catch(ret);
539
540 if (ret)
541 return -EFAULT;
542 }
543
544 return ret;
545}
546#endif
547
548long
549sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
550 struct pt_regs *regs)
551{
552 return do_sigaltstack(uss, uoss, regs->sp);
553}
554
555
556
557
558#ifdef CONFIG_X86_32
559unsigned long sys_sigreturn(struct pt_regs *regs)
560{
561 struct sigframe __user *frame;
562 unsigned long ax;
563 sigset_t set;
564
565 frame = (struct sigframe __user *)(regs->sp - 8);
566
567 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
568 goto badframe;
569 if (__get_user(set.sig[0], &frame->sc.oldmask) || (_NSIG_WORDS > 1
570 && __copy_from_user(&set.sig[1], &frame->extramask,
571 sizeof(frame->extramask))))
572 goto badframe;
573
574 sigdelsetmask(&set, ~_BLOCKABLE);
575 spin_lock_irq(¤t->sighand->siglock);
576 current->blocked = set;
577 recalc_sigpending();
578 spin_unlock_irq(¤t->sighand->siglock);
579
580 if (restore_sigcontext(regs, &frame->sc, &ax))
581 goto badframe;
582 return ax;
583
584badframe:
585 signal_fault(regs, frame, "sigreturn");
586
587 return 0;
588}
589#endif
590
591long sys_rt_sigreturn(struct pt_regs *regs)
592{
593 struct rt_sigframe __user *frame;
594 unsigned long ax;
595 sigset_t set;
596
597 frame = (struct rt_sigframe __user *)(regs->sp - sizeof(long));
598 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
599 goto badframe;
600 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
601 goto badframe;
602
603 sigdelsetmask(&set, ~_BLOCKABLE);
604 spin_lock_irq(¤t->sighand->siglock);
605 current->blocked = set;
606 recalc_sigpending();
607 spin_unlock_irq(¤t->sighand->siglock);
608
609 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax))
610 goto badframe;
611
612 if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT)
613 goto badframe;
614
615 return ax;
616
617badframe:
618 signal_fault(regs, frame, "rt_sigreturn");
619 return 0;
620}
621
622
623
624
625static int signr_convert(int sig)
626{
627#ifdef CONFIG_X86_32
628 struct thread_info *info = current_thread_info();
629
630 if (info->exec_domain && info->exec_domain->signal_invmap && sig < 32)
631 return info->exec_domain->signal_invmap[sig];
632#endif
633 return sig;
634}
635
636#ifdef CONFIG_X86_32
637
638#define is_ia32 1
639#define ia32_setup_frame __setup_frame
640#define ia32_setup_rt_frame __setup_rt_frame
641
642#else
643
644#ifdef CONFIG_IA32_EMULATION
645#define is_ia32 test_thread_flag(TIF_IA32)
646#else
647#define is_ia32 0
648#endif
649
650int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
651 sigset_t *set, struct pt_regs *regs);
652int ia32_setup_frame(int sig, struct k_sigaction *ka,
653 sigset_t *set, struct pt_regs *regs);
654
655#endif
656
657static int
658setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
659 sigset_t *set, struct pt_regs *regs)
660{
661 int usig = signr_convert(sig);
662 int ret;
663
664
665 if (is_ia32) {
666 if (ka->sa.sa_flags & SA_SIGINFO)
667 ret = ia32_setup_rt_frame(usig, ka, info, set, regs);
668 else
669 ret = ia32_setup_frame(usig, ka, set, regs);
670 } else
671 ret = __setup_rt_frame(sig, ka, info, set, regs);
672
673 if (ret) {
674 force_sigsegv(sig, current);
675 return -EFAULT;
676 }
677
678 return ret;
679}
680
681static int
682handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
683 sigset_t *oldset, struct pt_regs *regs)
684{
685 int ret;
686
687
688 if (syscall_get_nr(current, regs) >= 0) {
689
690 switch (syscall_get_error(current, regs)) {
691 case -ERESTART_RESTARTBLOCK:
692 case -ERESTARTNOHAND:
693 regs->ax = -EINTR;
694 break;
695
696 case -ERESTARTSYS:
697 if (!(ka->sa.sa_flags & SA_RESTART)) {
698 regs->ax = -EINTR;
699 break;
700 }
701
702 case -ERESTARTNOINTR:
703 regs->ax = regs->orig_ax;
704 regs->ip -= 2;
705 break;
706 }
707 }
708
709
710
711
712
713 if (unlikely(regs->flags & X86_EFLAGS_TF) &&
714 likely(test_and_clear_thread_flag(TIF_FORCED_TF)))
715 regs->flags &= ~X86_EFLAGS_TF;
716
717 ret = setup_rt_frame(sig, ka, info, oldset, regs);
718
719 if (ret)
720 return ret;
721
722#ifdef CONFIG_X86_64
723
724
725
726
727
728 set_fs(USER_DS);
729#endif
730
731
732
733
734 regs->flags &= ~X86_EFLAGS_DF;
735
736
737
738
739
740
741
742 regs->flags &= ~X86_EFLAGS_TF;
743
744 spin_lock_irq(¤t->sighand->siglock);
745 sigorsets(¤t->blocked, ¤t->blocked, &ka->sa.sa_mask);
746 if (!(ka->sa.sa_flags & SA_NODEFER))
747 sigaddset(¤t->blocked, sig);
748 recalc_sigpending();
749 spin_unlock_irq(¤t->sighand->siglock);
750
751 tracehook_signal_handler(sig, info, ka, regs,
752 test_thread_flag(TIF_SINGLESTEP));
753
754 return 0;
755}
756
757#ifdef CONFIG_X86_32
758#define NR_restart_syscall __NR_restart_syscall
759#else
760#define NR_restart_syscall \
761 test_thread_flag(TIF_IA32) ? __NR_ia32_restart_syscall : __NR_restart_syscall
762#endif
763
764
765
766
767
768
769static void do_signal(struct pt_regs *regs)
770{
771 struct k_sigaction ka;
772 siginfo_t info;
773 int signr;
774 sigset_t *oldset;
775
776
777
778
779
780
781
782
783 if (!user_mode(regs))
784 return;
785
786 if (current_thread_info()->status & TS_RESTORE_SIGMASK)
787 oldset = ¤t->saved_sigmask;
788 else
789 oldset = ¤t->blocked;
790
791 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
792 if (signr > 0) {
793
794 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
795
796
797
798
799
800
801 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
802 }
803 return;
804 }
805
806
807 if (syscall_get_nr(current, regs) >= 0) {
808
809 switch (syscall_get_error(current, regs)) {
810 case -ERESTARTNOHAND:
811 case -ERESTARTSYS:
812 case -ERESTARTNOINTR:
813 regs->ax = regs->orig_ax;
814 regs->ip -= 2;
815 break;
816
817 case -ERESTART_RESTARTBLOCK:
818 regs->ax = NR_restart_syscall;
819 regs->ip -= 2;
820 break;
821 }
822 }
823
824
825
826
827
828 if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
829 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
830 sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL);
831 }
832}
833
834
835
836
837
838void
839do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)
840{
841#ifdef CONFIG_X86_MCE
842
843 if (thread_info_flags & _TIF_MCE_NOTIFY)
844 mce_notify_process();
845#endif
846
847
848 if (thread_info_flags & _TIF_SIGPENDING)
849 do_signal(regs);
850
851 if (thread_info_flags & _TIF_NOTIFY_RESUME) {
852 clear_thread_flag(TIF_NOTIFY_RESUME);
853 tracehook_notify_resume(regs);
854 if (current->replacement_session_keyring)
855 key_replace_session_keyring();
856 }
857 if (thread_info_flags & _TIF_USER_RETURN_NOTIFY)
858 fire_user_return_notifiers();
859
860#ifdef CONFIG_X86_32
861 clear_thread_flag(TIF_IRET);
862#endif
863}
864
865void signal_fault(struct pt_regs *regs, void __user *frame, char *where)
866{
867 struct task_struct *me = current;
868
869 if (show_unhandled_signals && printk_ratelimit()) {
870 printk("%s"
871 "%s[%d] bad frame in %s frame:%p ip:%lx sp:%lx orax:%lx",
872 task_pid_nr(current) > 1 ? KERN_INFO : KERN_EMERG,
873 me->comm, me->pid, where, frame,
874 regs->ip, regs->sp, regs->orig_ax);
875 print_vma_addr(" in ", regs->ip);
876 printk(KERN_CONT "\n");
877 }
878
879 force_sig(SIGSEGV, me);
880}
881