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