blob: e9f71298e746723a1af4962b59e05824704b2ed0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Copyright (C) 1991, 1992 Linus Torvalds
3 *
4 * 1997-11-28 Modified for POSIX.1b signals by Richard Henderson
5 * 2000-06-20 Pentium III FXSR, SSE support by Gareth Hughes
6 */
7
Ingo Molnar7e907f42008-03-06 10:33:08 +01008#include <linux/sched.h>
Ingo Molnar7e907f42008-03-06 10:33:08 +01009#include <linux/mm.h>
Hiroshi Shimamoto5c9b3a02008-11-21 17:36:41 -080010#include <linux/smp.h>
11#include <linux/kernel.h>
12#include <linux/signal.h>
13#include <linux/errno.h>
14#include <linux/wait.h>
15#include <linux/ptrace.h>
16#include <linux/tracehook.h>
17#include <linux/unistd.h>
18#include <linux/stddef.h>
19#include <linux/personality.h>
20#include <linux/uaccess.h>
Ingo Molnar7e907f42008-03-06 10:33:08 +010021
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <asm/processor.h>
23#include <asm/ucontext.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <asm/i387.h>
Roland McGrath6c3652e2008-01-30 13:30:42 +010025#include <asm/vdso.h>
Hiroshi Shimamoto5c9b3a02008-11-21 17:36:41 -080026
27#ifdef CONFIG_X86_64
28#include <asm/proto.h>
29#include <asm/ia32_unistd.h>
30#include <asm/mce.h>
31#endif /* CONFIG_X86_64 */
32
Hiroshi Shimamotobb579252008-09-05 16:26:55 -070033#include <asm/syscall.h>
Jaswinder Singhbbc1f692008-07-21 21:34:13 +053034#include <asm/syscalls.h>
Ingo Molnar7e907f42008-03-06 10:33:08 +010035
Harvey Harrison123a6342008-02-08 12:10:00 -080036#include "sigframe.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
39
Harvey Harrison1a176802008-02-08 12:09:59 -080040#define __FIX_EFLAGS (X86_EFLAGS_AC | X86_EFLAGS_OF | \
41 X86_EFLAGS_DF | X86_EFLAGS_TF | X86_EFLAGS_SF | \
42 X86_EFLAGS_ZF | X86_EFLAGS_AF | X86_EFLAGS_PF | \
43 X86_EFLAGS_CF)
44
45#ifdef CONFIG_X86_32
46# define FIX_EFLAGS (__FIX_EFLAGS | X86_EFLAGS_RF)
47#else
48# define FIX_EFLAGS __FIX_EFLAGS
49#endif
50
Hiroshi Shimamoto26016572008-11-24 18:21:37 -080051#define COPY(x) { \
52 err |= __get_user(regs->x, &sc->x); \
53}
54
55#define COPY_SEG(seg) { \
56 unsigned short tmp; \
57 err |= __get_user(tmp, &sc->seg); \
58 regs->seg = tmp; \
59}
60
61#define COPY_SEG_CPL3(seg) { \
62 unsigned short tmp; \
63 err |= __get_user(tmp, &sc->seg); \
64 regs->seg = tmp | 3; \
65}
66
67#define GET_SEG(seg) { \
68 unsigned short tmp; \
69 err |= __get_user(tmp, &sc->seg); \
70 loadsegment(seg, tmp); \
71}
72
73static int
74restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc,
75 unsigned long *pax)
76{
77 void __user *buf;
78 unsigned int tmpflags;
79 unsigned int err = 0;
80
81 /* Always make any pending restarted system calls return -EINTR */
82 current_thread_info()->restart_block.fn = do_no_restart_syscall;
83
84#ifdef CONFIG_X86_32
85 GET_SEG(gs);
86 COPY_SEG(fs);
87 COPY_SEG(es);
88 COPY_SEG(ds);
89#endif /* CONFIG_X86_32 */
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 /* CONFIG_X86_64 */
104
105#ifdef CONFIG_X86_32
106 COPY_SEG_CPL3(cs);
107 COPY_SEG_CPL3(ss);
108#else /* !CONFIG_X86_32 */
109 /* Kernel saves and restores only the CS segment register on signals,
110 * which is the bare minimum needed to allow mixed 32/64-bit code.
111 * App's signal handler can save/restore other segments if needed. */
112 COPY_SEG_CPL3(cs);
113#endif /* CONFIG_X86_32 */
114
115 err |= __get_user(tmpflags, &sc->flags);
116 regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
117 regs->orig_ax = -1; /* disable syscall checks */
118
119 err |= __get_user(buf, &sc->fpstate);
120 err |= restore_i387_xstate(buf);
121
122 err |= __get_user(*pax, &sc->ax);
123 return err;
124}
125
126static int
127setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
128 struct pt_regs *regs, unsigned long mask)
129{
130 int err = 0;
131
132#ifdef CONFIG_X86_32
133 {
134 unsigned int tmp;
135
136 savesegment(gs, tmp);
137 err |= __put_user(tmp, (unsigned int __user *)&sc->gs);
138 }
139 err |= __put_user(regs->fs, (unsigned int __user *)&sc->fs);
140 err |= __put_user(regs->es, (unsigned int __user *)&sc->es);
141 err |= __put_user(regs->ds, (unsigned int __user *)&sc->ds);
142#endif /* CONFIG_X86_32 */
143
144 err |= __put_user(regs->di, &sc->di);
145 err |= __put_user(regs->si, &sc->si);
146 err |= __put_user(regs->bp, &sc->bp);
147 err |= __put_user(regs->sp, &sc->sp);
148 err |= __put_user(regs->bx, &sc->bx);
149 err |= __put_user(regs->dx, &sc->dx);
150 err |= __put_user(regs->cx, &sc->cx);
151 err |= __put_user(regs->ax, &sc->ax);
152#ifdef CONFIG_X86_64
153 err |= __put_user(regs->r8, &sc->r8);
154 err |= __put_user(regs->r9, &sc->r9);
155 err |= __put_user(regs->r10, &sc->r10);
156 err |= __put_user(regs->r11, &sc->r11);
157 err |= __put_user(regs->r12, &sc->r12);
158 err |= __put_user(regs->r13, &sc->r13);
159 err |= __put_user(regs->r14, &sc->r14);
160 err |= __put_user(regs->r15, &sc->r15);
161#endif /* CONFIG_X86_64 */
162
163 err |= __put_user(current->thread.trap_no, &sc->trapno);
164 err |= __put_user(current->thread.error_code, &sc->err);
165 err |= __put_user(regs->ip, &sc->ip);
166#ifdef CONFIG_X86_32
167 err |= __put_user(regs->cs, (unsigned int __user *)&sc->cs);
168 err |= __put_user(regs->flags, &sc->flags);
169 err |= __put_user(regs->sp, &sc->sp_at_signal);
170 err |= __put_user(regs->ss, (unsigned int __user *)&sc->ss);
171#else /* !CONFIG_X86_32 */
172 err |= __put_user(regs->flags, &sc->flags);
173 err |= __put_user(regs->cs, &sc->cs);
174 err |= __put_user(0, &sc->gs);
175 err |= __put_user(0, &sc->fs);
176#endif /* CONFIG_X86_32 */
177
178 err |= __put_user(fpstate, &sc->fpstate);
179
180 /* non-iBCS2 extensions.. */
181 err |= __put_user(mask, &sc->oldmask);
182 err |= __put_user(current->thread.cr2, &sc->cr2);
183
184 return err;
185}
186
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 * Set up a signal frame.
189 */
Hiroshi Shimamotobfeb91a2008-11-24 18:23:12 -0800190#ifdef CONFIG_X86_32
191static const struct {
192 u16 poplmovl;
193 u32 val;
194 u16 int80;
195} __attribute__((packed)) retcode = {
196 0xb858, /* popl %eax; movl $..., %eax */
197 __NR_sigreturn,
198 0x80cd, /* int $0x80 */
199};
200
201static const struct {
202 u8 movl;
203 u32 val;
204 u16 int80;
205 u8 pad;
206} __attribute__((packed)) rt_retcode = {
207 0xb8, /* movl $..., %eax */
208 __NR_rt_sigreturn,
209 0x80cd, /* int $0x80 */
210 0
211};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212
213/*
214 * Determine which stack to use..
215 */
216static inline void __user *
Suresh Siddha3c1c7f12008-07-29 10:29:21 -0700217get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
Suresh Siddhaab513702008-07-29 10:29:22 -0700218 void **fpstate)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219{
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100220 unsigned long sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221
222 /* Default to using normal stack */
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100223 sp = regs->sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224
Roland McGrath83bd0102008-01-30 13:30:06 +0100225 /*
226 * If we are on the alternate signal stack and would overflow it, don't.
227 * Return an always-bogus address instead so we will die with SIGSEGV.
228 */
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100229 if (on_sig_stack(sp) && !likely(on_sig_stack(sp - frame_size)))
Roland McGrath83bd0102008-01-30 13:30:06 +0100230 return (void __user *) -1L;
231
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 /* This is the X/Open sanctioned signal stack switching. */
233 if (ka->sa.sa_flags & SA_ONSTACK) {
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100234 if (sas_ss_flags(sp) == 0)
235 sp = current->sas_ss_sp + current->sas_ss_size;
Ingo Molnar7e907f42008-03-06 10:33:08 +0100236 } else {
237 /* This is the legacy signal stack switching. */
238 if ((regs->ss & 0xffff) != __USER_DS &&
239 !(ka->sa.sa_flags & SA_RESTORER) &&
240 ka->sa.sa_restorer)
241 sp = (unsigned long) ka->sa.sa_restorer;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 }
243
Suresh Siddha3c1c7f12008-07-29 10:29:21 -0700244 if (used_math()) {
245 sp = sp - sig_xstate_size;
246 *fpstate = (struct _fpstate *) sp;
Hiroshi Shimamoto4b336692008-11-05 18:30:25 -0800247 if (save_i387_xstate(*fpstate) < 0)
248 return (void __user *)-1L;
Suresh Siddha3c1c7f12008-07-29 10:29:21 -0700249 }
250
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100251 sp -= frame_size;
Ingo Molnar7e907f42008-03-06 10:33:08 +0100252 /*
253 * Align the stack pointer according to the i386 ABI,
254 * i.e. so that on function entry ((sp + 4) & 15) == 0.
255 */
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100256 sp = ((sp + 4) & -16ul) - 4;
Ingo Molnar7e907f42008-03-06 10:33:08 +0100257
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100258 return (void __user *) sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259}
260
Ingo Molnar7e907f42008-03-06 10:33:08 +0100261static int
Hiroshi Shimamoto1d130242008-09-05 16:28:06 -0700262__setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
263 struct pt_regs *regs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 struct sigframe __user *frame;
Ingo Molnar7e907f42008-03-06 10:33:08 +0100266 void __user *restorer;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 int err = 0;
Suresh Siddhaab513702008-07-29 10:29:22 -0700268 void __user *fpstate = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269
Suresh Siddha3c1c7f12008-07-29 10:29:21 -0700270 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
272 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
Hiroshi Shimamoto3d0aedd2008-09-12 17:01:09 -0700273 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274
Hiroshi Shimamoto2ba48e12008-09-12 17:02:53 -0700275 if (__put_user(sig, &frame->sig))
Hiroshi Shimamoto3d0aedd2008-09-12 17:01:09 -0700276 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Hiroshi Shimamoto2ba48e12008-09-12 17:02:53 -0700278 if (setup_sigcontext(&frame->sc, fpstate, regs, set->sig[0]))
Hiroshi Shimamoto3d0aedd2008-09-12 17:01:09 -0700279 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280
281 if (_NSIG_WORDS > 1) {
Hiroshi Shimamoto2ba48e12008-09-12 17:02:53 -0700282 if (__copy_to_user(&frame->extramask, &set->sig[1],
283 sizeof(frame->extramask)))
Hiroshi Shimamoto3d0aedd2008-09-12 17:01:09 -0700284 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 }
286
Roland McGrath1a3e4ca2008-04-09 01:29:27 -0700287 if (current->mm->context.vdso)
Roland McGrath6c3652e2008-01-30 13:30:42 +0100288 restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
Andi Kleen9fbbd4d2007-02-13 13:26:26 +0100289 else
Jan Engelhardtade1af72008-01-30 13:33:23 +0100290 restorer = &frame->retcode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 if (ka->sa.sa_flags & SA_RESTORER)
292 restorer = ka->sa.sa_restorer;
293
294 /* Set up to return from userspace. */
295 err |= __put_user(restorer, &frame->pretcode);
Ingo Molnar7e907f42008-03-06 10:33:08 +0100296
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 /*
Ingo Molnar7e907f42008-03-06 10:33:08 +0100298 * This is popl %eax ; movl $__NR_sigreturn, %eax ; int $0x80
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 *
300 * WE DO NOT USE IT ANY MORE! It's only left here for historical
301 * reasons and because gdb uses it as a signature to notice
302 * signal handler stack frames.
303 */
Hiroshi Shimamoto4a612042008-11-11 19:09:29 -0800304 err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
306 if (err)
Hiroshi Shimamoto3d0aedd2008-09-12 17:01:09 -0700307 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
309 /* Set up registers for signal handler */
Ingo Molnar7e907f42008-03-06 10:33:08 +0100310 regs->sp = (unsigned long)frame;
311 regs->ip = (unsigned long)ka->sa.sa_handler;
312 regs->ax = (unsigned long)sig;
Harvey Harrison92bc2052008-02-08 12:09:56 -0800313 regs->dx = 0;
314 regs->cx = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100316 regs->ds = __USER_DS;
317 regs->es = __USER_DS;
318 regs->ss = __USER_DS;
319 regs->cs = __USER_CS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
David Howells283828f2006-01-18 17:44:00 -0800321 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322}
323
Hiroshi Shimamoto1d130242008-09-05 16:28:06 -0700324static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
325 sigset_t *set, struct pt_regs *regs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 struct rt_sigframe __user *frame;
Ingo Molnar7e907f42008-03-06 10:33:08 +0100328 void __user *restorer;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 int err = 0;
Suresh Siddhaab513702008-07-29 10:29:22 -0700330 void __user *fpstate = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331
Suresh Siddha3c1c7f12008-07-29 10:29:21 -0700332 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333
334 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
Hiroshi Shimamoto3d0aedd2008-09-12 17:01:09 -0700335 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336
Hiroshi Shimamoto13ad7722008-09-05 16:28:38 -0700337 err |= __put_user(sig, &frame->sig);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 err |= __put_user(&frame->info, &frame->pinfo);
339 err |= __put_user(&frame->uc, &frame->puc);
340 err |= copy_siginfo_to_user(&frame->info, info);
341 if (err)
Hiroshi Shimamoto3d0aedd2008-09-12 17:01:09 -0700342 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
344 /* Create the ucontext. */
Suresh Siddhac37b5ef2008-07-29 10:29:25 -0700345 if (cpu_has_xsave)
346 err |= __put_user(UC_FP_XSTATE, &frame->uc.uc_flags);
347 else
348 err |= __put_user(0, &frame->uc.uc_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 err |= __put_user(0, &frame->uc.uc_link);
350 err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100351 err |= __put_user(sas_ss_flags(regs->sp),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 &frame->uc.uc_stack.ss_flags);
353 err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
Suresh Siddha3c1c7f12008-07-29 10:29:21 -0700354 err |= setup_sigcontext(&frame->uc.uc_mcontext, fpstate,
Ingo Molnar7e907f42008-03-06 10:33:08 +0100355 regs, set->sig[0]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
357 if (err)
Hiroshi Shimamoto3d0aedd2008-09-12 17:01:09 -0700358 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359
360 /* Set up to return from userspace. */
Roland McGrath6c3652e2008-01-30 13:30:42 +0100361 restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 if (ka->sa.sa_flags & SA_RESTORER)
363 restorer = ka->sa.sa_restorer;
364 err |= __put_user(restorer, &frame->pretcode);
Ingo Molnar7e907f42008-03-06 10:33:08 +0100365
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 /*
Ingo Molnar7e907f42008-03-06 10:33:08 +0100367 * This is movl $__NR_rt_sigreturn, %ax ; int $0x80
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 *
369 * WE DO NOT USE IT ANY MORE! It's only left here for historical
370 * reasons and because gdb uses it as a signature to notice
371 * signal handler stack frames.
372 */
Hiroshi Shimamoto4a612042008-11-11 19:09:29 -0800373 err |= __put_user(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374
375 if (err)
Hiroshi Shimamoto3d0aedd2008-09-12 17:01:09 -0700376 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377
378 /* Set up registers for signal handler */
Ingo Molnar7e907f42008-03-06 10:33:08 +0100379 regs->sp = (unsigned long)frame;
380 regs->ip = (unsigned long)ka->sa.sa_handler;
Hiroshi Shimamoto13ad7722008-09-05 16:28:38 -0700381 regs->ax = (unsigned long)sig;
Ingo Molnar7e907f42008-03-06 10:33:08 +0100382 regs->dx = (unsigned long)&frame->info;
383 regs->cx = (unsigned long)&frame->uc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100385 regs->ds = __USER_DS;
386 regs->es = __USER_DS;
387 regs->ss = __USER_DS;
388 regs->cs = __USER_CS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389
David Howells283828f2006-01-18 17:44:00 -0800390 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391}
Hiroshi Shimamotobfeb91a2008-11-24 18:23:12 -0800392#else /* !CONFIG_X86_32 */
393/*
394 * Determine which stack to use..
395 */
396static void __user *
397get_stack(struct k_sigaction *ka, unsigned long sp, unsigned long size)
398{
399 /* Default to using normal stack - redzone*/
400 sp -= 128;
401
402 /* This is the X/Open sanctioned signal stack switching. */
403 if (ka->sa.sa_flags & SA_ONSTACK) {
404 if (sas_ss_flags(sp) == 0)
405 sp = current->sas_ss_sp + current->sas_ss_size;
406 }
407
408 return (void __user *)round_down(sp - size, 64);
409}
410
411static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
412 sigset_t *set, struct pt_regs *regs)
413{
414 struct rt_sigframe __user *frame;
415 void __user *fp = NULL;
416 int err = 0;
417 struct task_struct *me = current;
418
419 if (used_math()) {
420 fp = get_stack(ka, regs->sp, sig_xstate_size);
421 frame = (void __user *)round_down(
422 (unsigned long)fp - sizeof(struct rt_sigframe), 16) - 8;
423
424 if (save_i387_xstate(fp) < 0)
425 return -EFAULT;
426 } else
427 frame = get_stack(ka, regs->sp, sizeof(struct rt_sigframe)) - 8;
428
429 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
430 return -EFAULT;
431
432 if (ka->sa.sa_flags & SA_SIGINFO) {
433 if (copy_siginfo_to_user(&frame->info, info))
434 return -EFAULT;
435 }
436
437 /* Create the ucontext. */
438 if (cpu_has_xsave)
439 err |= __put_user(UC_FP_XSTATE, &frame->uc.uc_flags);
440 else
441 err |= __put_user(0, &frame->uc.uc_flags);
442 err |= __put_user(0, &frame->uc.uc_link);
443 err |= __put_user(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp);
444 err |= __put_user(sas_ss_flags(regs->sp),
445 &frame->uc.uc_stack.ss_flags);
446 err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
447 err |= setup_sigcontext(&frame->uc.uc_mcontext, fp, regs, set->sig[0]);
448 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
449
450 /* Set up to return from userspace. If provided, use a stub
451 already in userspace. */
452 /* x86-64 should always use SA_RESTORER. */
453 if (ka->sa.sa_flags & SA_RESTORER) {
454 err |= __put_user(ka->sa.sa_restorer, &frame->pretcode);
455 } else {
456 /* could use a vstub here */
457 return -EFAULT;
458 }
459
460 if (err)
461 return -EFAULT;
462
463 /* Set up registers for signal handler */
464 regs->di = sig;
465 /* In case the signal handler was declared without prototypes */
466 regs->ax = 0;
467
468 /* This also works for non SA_SIGINFO handlers because they expect the
469 next argument after the signal number on the stack. */
470 regs->si = (unsigned long)&frame->info;
471 regs->dx = (unsigned long)&frame->uc;
472 regs->ip = (unsigned long) ka->sa.sa_handler;
473
474 regs->sp = (unsigned long)frame;
475
476 /* Set up the CS register to run signal handlers in 64-bit mode,
477 even if the handler happens to be interrupting 32-bit code. */
478 regs->cs = __USER_CS;
479
480 return 0;
481}
482#endif /* CONFIG_X86_32 */
483
484/*
485 * Atomically swap in the new signal mask, and wait for a signal.
486 */
487asmlinkage int
488sys_sigsuspend(int history0, int history1, old_sigset_t mask)
489{
490 mask &= _BLOCKABLE;
491 spin_lock_irq(&current->sighand->siglock);
492 current->saved_sigmask = current->blocked;
493 siginitset(&current->blocked, mask);
494 recalc_sigpending();
495 spin_unlock_irq(&current->sighand->siglock);
496
497 current->state = TASK_INTERRUPTIBLE;
498 schedule();
499 set_restore_sigmask();
500
501 return -ERESTARTNOHAND;
502}
503
504asmlinkage int
505sys_sigaction(int sig, const struct old_sigaction __user *act,
506 struct old_sigaction __user *oact)
507{
508 struct k_sigaction new_ka, old_ka;
509 int ret;
510
511 if (act) {
512 old_sigset_t mask;
513
514 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
515 __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
516 __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
517 return -EFAULT;
518
519 __get_user(new_ka.sa.sa_flags, &act->sa_flags);
520 __get_user(mask, &act->sa_mask);
521 siginitset(&new_ka.sa.sa_mask, mask);
522 }
523
524 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
525
526 if (!ret && oact) {
527 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
528 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
529 __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
530 return -EFAULT;
531
532 __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
533 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
534 }
535
536 return ret;
537}
538
539#ifdef CONFIG_X86_32
540asmlinkage int sys_sigaltstack(unsigned long bx)
541{
542 /*
543 * This is needed to make gcc realize it doesn't own the
544 * "struct pt_regs"
545 */
546 struct pt_regs *regs = (struct pt_regs *)&bx;
547 const stack_t __user *uss = (const stack_t __user *)bx;
548 stack_t __user *uoss = (stack_t __user *)regs->cx;
549
550 return do_sigaltstack(uss, uoss, regs->sp);
551}
552#else /* !CONFIG_X86_32 */
553asmlinkage long
554sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
555 struct pt_regs *regs)
556{
557 return do_sigaltstack(uss, uoss, regs->sp);
558}
559#endif /* CONFIG_X86_32 */
560
561/*
562 * Do a signal return; undo the signal stack.
563 */
564asmlinkage unsigned long sys_sigreturn(unsigned long __unused)
565{
566 struct sigframe __user *frame;
567 struct pt_regs *regs;
568 unsigned long ax;
569 sigset_t set;
570
571 regs = (struct pt_regs *) &__unused;
572 frame = (struct sigframe __user *)(regs->sp - 8);
573
574 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
575 goto badframe;
576 if (__get_user(set.sig[0], &frame->sc.oldmask) || (_NSIG_WORDS > 1
577 && __copy_from_user(&set.sig[1], &frame->extramask,
578 sizeof(frame->extramask))))
579 goto badframe;
580
581 sigdelsetmask(&set, ~_BLOCKABLE);
582 spin_lock_irq(&current->sighand->siglock);
583 current->blocked = set;
584 recalc_sigpending();
585 spin_unlock_irq(&current->sighand->siglock);
586
587 if (restore_sigcontext(regs, &frame->sc, &ax))
588 goto badframe;
589 return ax;
590
591badframe:
592 if (show_unhandled_signals && printk_ratelimit()) {
593 printk("%s%s[%d] bad frame in sigreturn frame:"
594 "%p ip:%lx sp:%lx oeax:%lx",
595 task_pid_nr(current) > 1 ? KERN_INFO : KERN_EMERG,
596 current->comm, task_pid_nr(current), frame, regs->ip,
597 regs->sp, regs->orig_ax);
598 print_vma_addr(" in ", regs->ip);
599 printk(KERN_CONT "\n");
600 }
601
602 force_sig(SIGSEGV, current);
603
604 return 0;
605}
606
607static long do_rt_sigreturn(struct pt_regs *regs)
608{
609 struct rt_sigframe __user *frame;
610 unsigned long ax;
611 sigset_t set;
612
613 frame = (struct rt_sigframe __user *)(regs->sp - sizeof(long));
614 if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
615 goto badframe;
616 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
617 goto badframe;
618
619 sigdelsetmask(&set, ~_BLOCKABLE);
620 spin_lock_irq(&current->sighand->siglock);
621 current->blocked = set;
622 recalc_sigpending();
623 spin_unlock_irq(&current->sighand->siglock);
624
625 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax))
626 goto badframe;
627
628 if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT)
629 goto badframe;
630
631 return ax;
632
633badframe:
634 signal_fault(regs, frame, "rt_sigreturn");
635 return 0;
636}
637
638#ifdef CONFIG_X86_32
639asmlinkage int sys_rt_sigreturn(unsigned long __unused)
640{
641 struct pt_regs *regs = (struct pt_regs *)&__unused;
642
643 return do_rt_sigreturn(regs);
644}
645#else /* !CONFIG_X86_32 */
646asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
647{
648 return do_rt_sigreturn(regs);
649}
650#endif /* CONFIG_X86_32 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651
652/*
Ingo Molnar7e907f42008-03-06 10:33:08 +0100653 * OK, we're invoking a handler:
654 */
Hiroshi Shimamoto8d8c13b2008-09-24 19:10:29 -0700655static int signr_convert(int sig)
656{
Hiroshi Shimamoto96bf84b2008-10-29 18:44:08 -0700657#ifdef CONFIG_X86_32
Hiroshi Shimamoto8d8c13b2008-09-24 19:10:29 -0700658 struct thread_info *info = current_thread_info();
659
660 if (info->exec_domain && info->exec_domain->signal_invmap && sig < 32)
661 return info->exec_domain->signal_invmap[sig];
Hiroshi Shimamoto96bf84b2008-10-29 18:44:08 -0700662#endif /* CONFIG_X86_32 */
Hiroshi Shimamoto8d8c13b2008-09-24 19:10:29 -0700663 return sig;
664}
665
Hiroshi Shimamotocabf5032008-10-29 18:46:07 -0700666#ifdef CONFIG_X86_32
667
Hiroshi Shimamoto455edbc2008-09-24 19:13:11 -0700668#define is_ia32 1
Hiroshi Shimamoto4694d232008-09-24 19:13:29 -0700669#define ia32_setup_frame __setup_frame
670#define ia32_setup_rt_frame __setup_rt_frame
Hiroshi Shimamoto455edbc2008-09-24 19:13:11 -0700671
Hiroshi Shimamotocabf5032008-10-29 18:46:07 -0700672#else /* !CONFIG_X86_32 */
673
674#ifdef CONFIG_IA32_EMULATION
675#define is_ia32 test_thread_flag(TIF_IA32)
676#else /* !CONFIG_IA32_EMULATION */
677#define is_ia32 0
678#endif /* CONFIG_IA32_EMULATION */
679
680#endif /* CONFIG_X86_32 */
681
Roland McGrath7c1def12005-06-23 00:08:21 -0700682static int
Hiroshi Shimamoto1d130242008-09-05 16:28:06 -0700683setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
684 sigset_t *set, struct pt_regs *regs)
685{
Hiroshi Shimamoto8d8c13b2008-09-24 19:10:29 -0700686 int usig = signr_convert(sig);
Hiroshi Shimamoto1d130242008-09-05 16:28:06 -0700687 int ret;
688
689 /* Set up the stack frame */
Hiroshi Shimamoto455edbc2008-09-24 19:13:11 -0700690 if (is_ia32) {
691 if (ka->sa.sa_flags & SA_SIGINFO)
Hiroshi Shimamoto4694d232008-09-24 19:13:29 -0700692 ret = ia32_setup_rt_frame(usig, ka, info, set, regs);
Hiroshi Shimamoto455edbc2008-09-24 19:13:11 -0700693 else
Hiroshi Shimamoto4694d232008-09-24 19:13:29 -0700694 ret = ia32_setup_frame(usig, ka, set, regs);
Hiroshi Shimamoto455edbc2008-09-24 19:13:11 -0700695 } else
696 ret = __setup_rt_frame(sig, ka, info, set, regs);
Hiroshi Shimamoto1d130242008-09-05 16:28:06 -0700697
Hiroshi Shimamoto3d0aedd2008-09-12 17:01:09 -0700698 if (ret) {
699 force_sigsegv(sig, current);
700 return -EFAULT;
701 }
702
Hiroshi Shimamoto1d130242008-09-05 16:28:06 -0700703 return ret;
704}
705
706static int
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
Harvey Harrisonac66f3f2008-02-08 12:09:58 -0800708 sigset_t *oldset, struct pt_regs *regs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709{
Roland McGrath7c1def12005-06-23 00:08:21 -0700710 int ret;
711
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 /* Are we from a system call? */
Hiroshi Shimamotobb579252008-09-05 16:26:55 -0700713 if (syscall_get_nr(current, regs) >= 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 /* If so, check system call restarting.. */
Hiroshi Shimamotobb579252008-09-05 16:26:55 -0700715 switch (syscall_get_error(current, regs)) {
Harvey Harrisonac66f3f2008-02-08 12:09:58 -0800716 case -ERESTART_RESTARTBLOCK:
717 case -ERESTARTNOHAND:
718 regs->ax = -EINTR;
719 break;
720
721 case -ERESTARTSYS:
722 if (!(ka->sa.sa_flags & SA_RESTART)) {
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100723 regs->ax = -EINTR;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 break;
Harvey Harrisonac66f3f2008-02-08 12:09:58 -0800725 }
726 /* fallthrough */
727 case -ERESTARTNOINTR:
728 regs->ax = regs->orig_ax;
729 regs->ip -= 2;
730 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 }
732 }
733
734 /*
Roland McGrathe1f28772008-01-30 13:30:50 +0100735 * If TF is set due to a debugger (TIF_FORCED_TF), clear the TF
736 * flag so that register information in the sigcontext is correct.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 */
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100738 if (unlikely(regs->flags & X86_EFLAGS_TF) &&
Roland McGrathe1f28772008-01-30 13:30:50 +0100739 likely(test_and_clear_thread_flag(TIF_FORCED_TF)))
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100740 regs->flags &= ~X86_EFLAGS_TF;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741
Hiroshi Shimamoto1d130242008-09-05 16:28:06 -0700742 ret = setup_rt_frame(sig, ka, info, oldset, regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743
Ingo Molnar7e907f42008-03-06 10:33:08 +0100744 if (ret)
745 return ret;
Roland McGrath7c1def12005-06-23 00:08:21 -0700746
Hiroshi Shimamoto86d32372008-09-23 17:22:32 -0700747#ifdef CONFIG_X86_64
748 /*
749 * This has nothing to do with segment registers,
750 * despite the name. This magic affects uaccess.h
751 * macros' behavior. Reset it to the normal setting.
752 */
753 set_fs(USER_DS);
754#endif
755
Roland McGrath8b9c5ff2008-04-19 14:26:54 -0700756 /*
757 * Clear the direction flag as per the ABI for function entry.
758 */
759 regs->flags &= ~X86_EFLAGS_DF;
760
761 /*
762 * Clear TF when entering the signal handler, but
763 * notify any tracer that was single-stepping it.
764 * The tracer may want to single-step inside the
765 * handler too.
766 */
767 regs->flags &= ~X86_EFLAGS_TF;
Roland McGrath8b9c5ff2008-04-19 14:26:54 -0700768
Ingo Molnar7e907f42008-03-06 10:33:08 +0100769 spin_lock_irq(&current->sighand->siglock);
770 sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
771 if (!(ka->sa.sa_flags & SA_NODEFER))
772 sigaddset(&current->blocked, sig);
773 recalc_sigpending();
774 spin_unlock_irq(&current->sighand->siglock);
775
Roland McGrath36a03302008-03-14 17:46:38 -0700776 tracehook_signal_handler(sig, info, ka, regs,
777 test_thread_flag(TIF_SINGLESTEP));
778
Ingo Molnar7e907f42008-03-06 10:33:08 +0100779 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780}
781
Hiroshi Shimamoto57917752008-10-29 18:46:40 -0700782#ifdef CONFIG_X86_32
Hiroshi Shimamoto8fcd8e22008-09-05 16:27:39 -0700783#define NR_restart_syscall __NR_restart_syscall
Hiroshi Shimamoto57917752008-10-29 18:46:40 -0700784#else /* !CONFIG_X86_32 */
785#define NR_restart_syscall \
786 test_thread_flag(TIF_IA32) ? __NR_ia32_restart_syscall : __NR_restart_syscall
787#endif /* CONFIG_X86_32 */
788
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789/*
790 * Note that 'init' is a special process: it doesn't get signals it doesn't
791 * want to handle. Thus you cannot kill init even with a SIGKILL even by
792 * mistake.
793 */
Harvey Harrison75604d72008-01-30 13:31:17 +0100794static void do_signal(struct pt_regs *regs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795{
Harvey Harrisonac66f3f2008-02-08 12:09:58 -0800796 struct k_sigaction ka;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 siginfo_t info;
798 int signr;
David Howells283828f2006-01-18 17:44:00 -0800799 sigset_t *oldset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800
801 /*
Harvey Harrisonac66f3f2008-02-08 12:09:58 -0800802 * We want the common case to go fast, which is why we may in certain
803 * cases get here from kernel mode. Just return without doing anything
804 * if so.
805 * X86_32: vm86 regs switched out by assembly code before reaching
806 * here, so testing against kernel CS suffices.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 */
Vincent Hanquez717b5942005-06-23 00:08:45 -0700808 if (!user_mode(regs))
David Howells283828f2006-01-18 17:44:00 -0800809 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810
Roland McGrath5a8da0e2008-04-30 00:53:10 -0700811 if (current_thread_info()->status & TS_RESTORE_SIGMASK)
David Howells283828f2006-01-18 17:44:00 -0800812 oldset = &current->saved_sigmask;
813 else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 oldset = &current->blocked;
815
816 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
817 if (signr > 0) {
Ingo Molnar7e907f42008-03-06 10:33:08 +0100818 /*
819 * Re-enable any watchpoints before delivering the
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 * signal to user space. The processor register will
821 * have been cleared if the watchpoint triggered
822 * inside the kernel.
823 */
Harvey Harrisonac66f3f2008-02-08 12:09:58 -0800824 if (current->thread.debugreg7)
Roland McGrath0f534092008-01-30 13:30:59 +0100825 set_debugreg(current->thread.debugreg7, 7);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826
Ingo Molnar7e907f42008-03-06 10:33:08 +0100827 /* Whee! Actually deliver the signal. */
David Howells283828f2006-01-18 17:44:00 -0800828 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
Ingo Molnar7e907f42008-03-06 10:33:08 +0100829 /*
Roland McGrath5a8da0e2008-04-30 00:53:10 -0700830 * A signal was successfully delivered; the saved
David Howells283828f2006-01-18 17:44:00 -0800831 * sigmask will have been stored in the signal frame,
832 * and will be restored by sigreturn, so we can simply
Roland McGrath5a8da0e2008-04-30 00:53:10 -0700833 * clear the TS_RESTORE_SIGMASK flag.
Ingo Molnar7e907f42008-03-06 10:33:08 +0100834 */
Roland McGrath5a8da0e2008-04-30 00:53:10 -0700835 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
David Howells283828f2006-01-18 17:44:00 -0800836 }
David Howells283828f2006-01-18 17:44:00 -0800837 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 }
839
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840 /* Did we come from a system call? */
Hiroshi Shimamotobb579252008-09-05 16:26:55 -0700841 if (syscall_get_nr(current, regs) >= 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 /* Restart the system call - no handlers present */
Hiroshi Shimamotobb579252008-09-05 16:26:55 -0700843 switch (syscall_get_error(current, regs)) {
David Howells283828f2006-01-18 17:44:00 -0800844 case -ERESTARTNOHAND:
845 case -ERESTARTSYS:
846 case -ERESTARTNOINTR:
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100847 regs->ax = regs->orig_ax;
848 regs->ip -= 2;
David Howells283828f2006-01-18 17:44:00 -0800849 break;
850
851 case -ERESTART_RESTARTBLOCK:
Hiroshi Shimamoto8fcd8e22008-09-05 16:27:39 -0700852 regs->ax = NR_restart_syscall;
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100853 regs->ip -= 2;
David Howells283828f2006-01-18 17:44:00 -0800854 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855 }
856 }
David Howells283828f2006-01-18 17:44:00 -0800857
Harvey Harrisonac66f3f2008-02-08 12:09:58 -0800858 /*
859 * If there's no signal to deliver, we just put the saved sigmask
860 * back.
861 */
Roland McGrath5a8da0e2008-04-30 00:53:10 -0700862 if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
863 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
David Howells283828f2006-01-18 17:44:00 -0800864 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
865 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866}
867
868/*
869 * notification of userspace execution resumption
David Howells283828f2006-01-18 17:44:00 -0800870 * - triggered by the TIF_WORK_MASK flags
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 */
Ingo Molnar7e907f42008-03-06 10:33:08 +0100872void
873do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874{
Hiroshi Shimamotoee847c52008-09-23 17:21:45 -0700875#if defined(CONFIG_X86_64) && defined(CONFIG_X86_MCE)
876 /* notify userspace of pending MCEs */
877 if (thread_info_flags & _TIF_MCE_NOTIFY)
878 mce_notify_user();
879#endif /* CONFIG_X86_64 && CONFIG_X86_MCE */
880
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881 /* deal with pending signal delivery */
Roland McGrath5a8da0e2008-04-30 00:53:10 -0700882 if (thread_info_flags & _TIF_SIGPENDING)
David Howells283828f2006-01-18 17:44:00 -0800883 do_signal(regs);
Peter Zijlstra8f4d37e2008-01-25 21:08:29 +0100884
Roland McGrath59e52132008-04-19 19:10:57 -0700885 if (thread_info_flags & _TIF_NOTIFY_RESUME) {
886 clear_thread_flag(TIF_NOTIFY_RESUME);
887 tracehook_notify_resume(regs);
888 }
889
Hiroshi Shimamotoee847c52008-09-23 17:21:45 -0700890#ifdef CONFIG_X86_32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891 clear_thread_flag(TIF_IRET);
Hiroshi Shimamotoee847c52008-09-23 17:21:45 -0700892#endif /* CONFIG_X86_32 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893}
Hiroshi Shimamoto72fa50f2008-09-05 16:27:11 -0700894
895void signal_fault(struct pt_regs *regs, void __user *frame, char *where)
896{
897 struct task_struct *me = current;
898
899 if (show_unhandled_signals && printk_ratelimit()) {
900 printk(KERN_INFO
901 "%s[%d] bad frame in %s frame:%p ip:%lx sp:%lx orax:%lx",
902 me->comm, me->pid, where, frame,
903 regs->ip, regs->sp, regs->orig_ax);
904 print_vma_addr(" in ", regs->ip);
905 printk(KERN_CONT "\n");
906 }
907
908 force_sig(SIGSEGV, me);
909}