diff options
Diffstat (limited to 'arch/x86/kernel/signal_32.c')
-rw-r--r-- | arch/x86/kernel/signal_32.c | 273 |
1 files changed, 162 insertions, 111 deletions
diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c index 6fb5bcdd8933..d6dd057d0f22 100644 --- a/arch/x86/kernel/signal_32.c +++ b/arch/x86/kernel/signal_32.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
18 | #include <linux/sched.h> | 18 | #include <linux/sched.h> |
19 | #include <linux/wait.h> | 19 | #include <linux/wait.h> |
20 | #include <linux/tracehook.h> | ||
20 | #include <linux/elf.h> | 21 | #include <linux/elf.h> |
21 | #include <linux/smp.h> | 22 | #include <linux/smp.h> |
22 | #include <linux/mm.h> | 23 | #include <linux/mm.h> |
@@ -26,6 +27,8 @@ | |||
26 | #include <asm/uaccess.h> | 27 | #include <asm/uaccess.h> |
27 | #include <asm/i387.h> | 28 | #include <asm/i387.h> |
28 | #include <asm/vdso.h> | 29 | #include <asm/vdso.h> |
30 | #include <asm/syscall.h> | ||
31 | #include <asm/syscalls.h> | ||
29 | 32 | ||
30 | #include "sigframe.h" | 33 | #include "sigframe.h" |
31 | 34 | ||
@@ -110,6 +113,27 @@ asmlinkage int sys_sigaltstack(unsigned long bx) | |||
110 | return do_sigaltstack(uss, uoss, regs->sp); | 113 | return do_sigaltstack(uss, uoss, regs->sp); |
111 | } | 114 | } |
112 | 115 | ||
116 | #define COPY(x) { \ | ||
117 | err |= __get_user(regs->x, &sc->x); \ | ||
118 | } | ||
119 | |||
120 | #define COPY_SEG(seg) { \ | ||
121 | unsigned short tmp; \ | ||
122 | err |= __get_user(tmp, &sc->seg); \ | ||
123 | regs->seg = tmp; \ | ||
124 | } | ||
125 | |||
126 | #define COPY_SEG_STRICT(seg) { \ | ||
127 | unsigned short tmp; \ | ||
128 | err |= __get_user(tmp, &sc->seg); \ | ||
129 | regs->seg = tmp | 3; \ | ||
130 | } | ||
131 | |||
132 | #define GET_SEG(seg) { \ | ||
133 | unsigned short tmp; \ | ||
134 | err |= __get_user(tmp, &sc->seg); \ | ||
135 | loadsegment(seg, tmp); \ | ||
136 | } | ||
113 | 137 | ||
114 | /* | 138 | /* |
115 | * Do a signal return; undo the signal stack. | 139 | * Do a signal return; undo the signal stack. |
@@ -118,28 +142,13 @@ static int | |||
118 | restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, | 142 | restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, |
119 | unsigned long *pax) | 143 | unsigned long *pax) |
120 | { | 144 | { |
145 | void __user *buf; | ||
146 | unsigned int tmpflags; | ||
121 | unsigned int err = 0; | 147 | unsigned int err = 0; |
122 | 148 | ||
123 | /* Always make any pending restarted system calls return -EINTR */ | 149 | /* Always make any pending restarted system calls return -EINTR */ |
124 | current_thread_info()->restart_block.fn = do_no_restart_syscall; | 150 | current_thread_info()->restart_block.fn = do_no_restart_syscall; |
125 | 151 | ||
126 | #define COPY(x) err |= __get_user(regs->x, &sc->x) | ||
127 | |||
128 | #define COPY_SEG(seg) \ | ||
129 | { unsigned short tmp; \ | ||
130 | err |= __get_user(tmp, &sc->seg); \ | ||
131 | regs->seg = tmp; } | ||
132 | |||
133 | #define COPY_SEG_STRICT(seg) \ | ||
134 | { unsigned short tmp; \ | ||
135 | err |= __get_user(tmp, &sc->seg); \ | ||
136 | regs->seg = tmp|3; } | ||
137 | |||
138 | #define GET_SEG(seg) \ | ||
139 | { unsigned short tmp; \ | ||
140 | err |= __get_user(tmp, &sc->seg); \ | ||
141 | loadsegment(seg, tmp); } | ||
142 | |||
143 | GET_SEG(gs); | 152 | GET_SEG(gs); |
144 | COPY_SEG(fs); | 153 | COPY_SEG(fs); |
145 | COPY_SEG(es); | 154 | COPY_SEG(es); |
@@ -149,38 +158,15 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, | |||
149 | COPY_SEG_STRICT(cs); | 158 | COPY_SEG_STRICT(cs); |
150 | COPY_SEG_STRICT(ss); | 159 | COPY_SEG_STRICT(ss); |
151 | 160 | ||
152 | { | 161 | err |= __get_user(tmpflags, &sc->flags); |
153 | unsigned int tmpflags; | 162 | regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS); |
154 | 163 | regs->orig_ax = -1; /* disable syscall checks */ | |
155 | err |= __get_user(tmpflags, &sc->flags); | ||
156 | regs->flags = (regs->flags & ~FIX_EFLAGS) | | ||
157 | (tmpflags & FIX_EFLAGS); | ||
158 | regs->orig_ax = -1; /* disable syscall checks */ | ||
159 | } | ||
160 | 164 | ||
161 | { | 165 | err |= __get_user(buf, &sc->fpstate); |
162 | struct _fpstate __user *buf; | 166 | err |= restore_i387_xstate(buf); |
163 | |||
164 | err |= __get_user(buf, &sc->fpstate); | ||
165 | if (buf) { | ||
166 | if (!access_ok(VERIFY_READ, buf, sizeof(*buf))) | ||
167 | goto badframe; | ||
168 | err |= restore_i387(buf); | ||
169 | } else { | ||
170 | struct task_struct *me = current; | ||
171 | |||
172 | if (used_math()) { | ||
173 | clear_fpu(me); | ||
174 | clear_used_math(); | ||
175 | } | ||
176 | } | ||
177 | } | ||
178 | 167 | ||
179 | err |= __get_user(*pax, &sc->ax); | 168 | err |= __get_user(*pax, &sc->ax); |
180 | return err; | 169 | return err; |
181 | |||
182 | badframe: | ||
183 | return 1; | ||
184 | } | 170 | } |
185 | 171 | ||
186 | asmlinkage unsigned long sys_sigreturn(unsigned long __unused) | 172 | asmlinkage unsigned long sys_sigreturn(unsigned long __unused) |
@@ -226,9 +212,8 @@ badframe: | |||
226 | return 0; | 212 | return 0; |
227 | } | 213 | } |
228 | 214 | ||
229 | asmlinkage int sys_rt_sigreturn(unsigned long __unused) | 215 | static long do_rt_sigreturn(struct pt_regs *regs) |
230 | { | 216 | { |
231 | struct pt_regs *regs = (struct pt_regs *)&__unused; | ||
232 | struct rt_sigframe __user *frame; | 217 | struct rt_sigframe __user *frame; |
233 | unsigned long ax; | 218 | unsigned long ax; |
234 | sigset_t set; | 219 | sigset_t set; |
@@ -254,15 +239,22 @@ asmlinkage int sys_rt_sigreturn(unsigned long __unused) | |||
254 | return ax; | 239 | return ax; |
255 | 240 | ||
256 | badframe: | 241 | badframe: |
257 | force_sig(SIGSEGV, current); | 242 | signal_fault(regs, frame, "rt_sigreturn"); |
258 | return 0; | 243 | return 0; |
259 | } | 244 | } |
260 | 245 | ||
246 | asmlinkage int sys_rt_sigreturn(unsigned long __unused) | ||
247 | { | ||
248 | struct pt_regs *regs = (struct pt_regs *)&__unused; | ||
249 | |||
250 | return do_rt_sigreturn(regs); | ||
251 | } | ||
252 | |||
261 | /* | 253 | /* |
262 | * Set up a signal frame. | 254 | * Set up a signal frame. |
263 | */ | 255 | */ |
264 | static int | 256 | static int |
265 | setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate, | 257 | setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate, |
266 | struct pt_regs *regs, unsigned long mask) | 258 | struct pt_regs *regs, unsigned long mask) |
267 | { | 259 | { |
268 | int tmp, err = 0; | 260 | int tmp, err = 0; |
@@ -289,7 +281,7 @@ setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate, | |||
289 | err |= __put_user(regs->sp, &sc->sp_at_signal); | 281 | err |= __put_user(regs->sp, &sc->sp_at_signal); |
290 | err |= __put_user(regs->ss, (unsigned int __user *)&sc->ss); | 282 | err |= __put_user(regs->ss, (unsigned int __user *)&sc->ss); |
291 | 283 | ||
292 | tmp = save_i387(fpstate); | 284 | tmp = save_i387_xstate(fpstate); |
293 | if (tmp < 0) | 285 | if (tmp < 0) |
294 | err = 1; | 286 | err = 1; |
295 | else | 287 | else |
@@ -306,7 +298,8 @@ setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate, | |||
306 | * Determine which stack to use.. | 298 | * Determine which stack to use.. |
307 | */ | 299 | */ |
308 | static inline void __user * | 300 | static inline void __user * |
309 | get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size) | 301 | get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size, |
302 | void **fpstate) | ||
310 | { | 303 | { |
311 | unsigned long sp; | 304 | unsigned long sp; |
312 | 305 | ||
@@ -332,6 +325,11 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size) | |||
332 | sp = (unsigned long) ka->sa.sa_restorer; | 325 | sp = (unsigned long) ka->sa.sa_restorer; |
333 | } | 326 | } |
334 | 327 | ||
328 | if (used_math()) { | ||
329 | sp = sp - sig_xstate_size; | ||
330 | *fpstate = (struct _fpstate *) sp; | ||
331 | } | ||
332 | |||
335 | sp -= frame_size; | 333 | sp -= frame_size; |
336 | /* | 334 | /* |
337 | * Align the stack pointer according to the i386 ABI, | 335 | * Align the stack pointer according to the i386 ABI, |
@@ -343,38 +341,29 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size) | |||
343 | } | 341 | } |
344 | 342 | ||
345 | static int | 343 | static int |
346 | setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, | 344 | __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, |
347 | struct pt_regs *regs) | 345 | struct pt_regs *regs) |
348 | { | 346 | { |
349 | struct sigframe __user *frame; | 347 | struct sigframe __user *frame; |
350 | void __user *restorer; | 348 | void __user *restorer; |
351 | int err = 0; | 349 | int err = 0; |
352 | int usig; | 350 | void __user *fpstate = NULL; |
353 | 351 | ||
354 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 352 | frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate); |
355 | 353 | ||
356 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 354 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
357 | goto give_sigsegv; | 355 | return -EFAULT; |
358 | 356 | ||
359 | usig = current_thread_info()->exec_domain | 357 | if (__put_user(sig, &frame->sig)) |
360 | && current_thread_info()->exec_domain->signal_invmap | 358 | return -EFAULT; |
361 | && sig < 32 | ||
362 | ? current_thread_info()->exec_domain->signal_invmap[sig] | ||
363 | : sig; | ||
364 | 359 | ||
365 | err = __put_user(usig, &frame->sig); | 360 | if (setup_sigcontext(&frame->sc, fpstate, regs, set->sig[0])) |
366 | if (err) | 361 | return -EFAULT; |
367 | goto give_sigsegv; | ||
368 | |||
369 | err = setup_sigcontext(&frame->sc, &frame->fpstate, regs, set->sig[0]); | ||
370 | if (err) | ||
371 | goto give_sigsegv; | ||
372 | 362 | ||
373 | if (_NSIG_WORDS > 1) { | 363 | if (_NSIG_WORDS > 1) { |
374 | err = __copy_to_user(&frame->extramask, &set->sig[1], | 364 | if (__copy_to_user(&frame->extramask, &set->sig[1], |
375 | sizeof(frame->extramask)); | 365 | sizeof(frame->extramask))) |
376 | if (err) | 366 | return -EFAULT; |
377 | goto give_sigsegv; | ||
378 | } | 367 | } |
379 | 368 | ||
380 | if (current->mm->context.vdso) | 369 | if (current->mm->context.vdso) |
@@ -399,7 +388,7 @@ setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, | |||
399 | err |= __put_user(0x80cd, (short __user *)(frame->retcode+6)); | 388 | err |= __put_user(0x80cd, (short __user *)(frame->retcode+6)); |
400 | 389 | ||
401 | if (err) | 390 | if (err) |
402 | goto give_sigsegv; | 391 | return -EFAULT; |
403 | 392 | ||
404 | /* Set up registers for signal handler */ | 393 | /* Set up registers for signal handler */ |
405 | regs->sp = (unsigned long)frame; | 394 | regs->sp = (unsigned long)frame; |
@@ -414,50 +403,43 @@ setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, | |||
414 | regs->cs = __USER_CS; | 403 | regs->cs = __USER_CS; |
415 | 404 | ||
416 | return 0; | 405 | return 0; |
417 | |||
418 | give_sigsegv: | ||
419 | force_sigsegv(sig, current); | ||
420 | return -EFAULT; | ||
421 | } | 406 | } |
422 | 407 | ||
423 | static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | 408 | static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, |
424 | sigset_t *set, struct pt_regs *regs) | 409 | sigset_t *set, struct pt_regs *regs) |
425 | { | 410 | { |
426 | struct rt_sigframe __user *frame; | 411 | struct rt_sigframe __user *frame; |
427 | void __user *restorer; | 412 | void __user *restorer; |
428 | int err = 0; | 413 | int err = 0; |
429 | int usig; | 414 | void __user *fpstate = NULL; |
430 | 415 | ||
431 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 416 | frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate); |
432 | 417 | ||
433 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) | 418 | if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) |
434 | goto give_sigsegv; | 419 | return -EFAULT; |
435 | 420 | ||
436 | usig = current_thread_info()->exec_domain | 421 | err |= __put_user(sig, &frame->sig); |
437 | && current_thread_info()->exec_domain->signal_invmap | ||
438 | && sig < 32 | ||
439 | ? current_thread_info()->exec_domain->signal_invmap[sig] | ||
440 | : sig; | ||
441 | |||
442 | err |= __put_user(usig, &frame->sig); | ||
443 | err |= __put_user(&frame->info, &frame->pinfo); | 422 | err |= __put_user(&frame->info, &frame->pinfo); |
444 | err |= __put_user(&frame->uc, &frame->puc); | 423 | err |= __put_user(&frame->uc, &frame->puc); |
445 | err |= copy_siginfo_to_user(&frame->info, info); | 424 | err |= copy_siginfo_to_user(&frame->info, info); |
446 | if (err) | 425 | if (err) |
447 | goto give_sigsegv; | 426 | return -EFAULT; |
448 | 427 | ||
449 | /* Create the ucontext. */ | 428 | /* Create the ucontext. */ |
450 | err |= __put_user(0, &frame->uc.uc_flags); | 429 | if (cpu_has_xsave) |
430 | err |= __put_user(UC_FP_XSTATE, &frame->uc.uc_flags); | ||
431 | else | ||
432 | err |= __put_user(0, &frame->uc.uc_flags); | ||
451 | err |= __put_user(0, &frame->uc.uc_link); | 433 | err |= __put_user(0, &frame->uc.uc_link); |
452 | err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); | 434 | err |= __put_user(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); |
453 | err |= __put_user(sas_ss_flags(regs->sp), | 435 | err |= __put_user(sas_ss_flags(regs->sp), |
454 | &frame->uc.uc_stack.ss_flags); | 436 | &frame->uc.uc_stack.ss_flags); |
455 | err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size); | 437 | err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size); |
456 | err |= setup_sigcontext(&frame->uc.uc_mcontext, &frame->fpstate, | 438 | err |= setup_sigcontext(&frame->uc.uc_mcontext, fpstate, |
457 | regs, set->sig[0]); | 439 | regs, set->sig[0]); |
458 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); | 440 | err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); |
459 | if (err) | 441 | if (err) |
460 | goto give_sigsegv; | 442 | return -EFAULT; |
461 | 443 | ||
462 | /* Set up to return from userspace. */ | 444 | /* Set up to return from userspace. */ |
463 | restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn); | 445 | restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn); |
@@ -477,12 +459,12 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
477 | err |= __put_user(0x80cd, (short __user *)(frame->retcode+5)); | 459 | err |= __put_user(0x80cd, (short __user *)(frame->retcode+5)); |
478 | 460 | ||
479 | if (err) | 461 | if (err) |
480 | goto give_sigsegv; | 462 | return -EFAULT; |
481 | 463 | ||
482 | /* Set up registers for signal handler */ | 464 | /* Set up registers for signal handler */ |
483 | regs->sp = (unsigned long)frame; | 465 | regs->sp = (unsigned long)frame; |
484 | regs->ip = (unsigned long)ka->sa.sa_handler; | 466 | regs->ip = (unsigned long)ka->sa.sa_handler; |
485 | regs->ax = (unsigned long)usig; | 467 | regs->ax = (unsigned long)sig; |
486 | regs->dx = (unsigned long)&frame->info; | 468 | regs->dx = (unsigned long)&frame->info; |
487 | regs->cx = (unsigned long)&frame->uc; | 469 | regs->cx = (unsigned long)&frame->uc; |
488 | 470 | ||
@@ -492,15 +474,48 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
492 | regs->cs = __USER_CS; | 474 | regs->cs = __USER_CS; |
493 | 475 | ||
494 | return 0; | 476 | return 0; |
495 | |||
496 | give_sigsegv: | ||
497 | force_sigsegv(sig, current); | ||
498 | return -EFAULT; | ||
499 | } | 477 | } |
500 | 478 | ||
501 | /* | 479 | /* |
502 | * OK, we're invoking a handler: | 480 | * OK, we're invoking a handler: |
503 | */ | 481 | */ |
482 | static int signr_convert(int sig) | ||
483 | { | ||
484 | struct thread_info *info = current_thread_info(); | ||
485 | |||
486 | if (info->exec_domain && info->exec_domain->signal_invmap && sig < 32) | ||
487 | return info->exec_domain->signal_invmap[sig]; | ||
488 | return sig; | ||
489 | } | ||
490 | |||
491 | #define is_ia32 1 | ||
492 | #define ia32_setup_frame __setup_frame | ||
493 | #define ia32_setup_rt_frame __setup_rt_frame | ||
494 | |||
495 | static int | ||
496 | setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | ||
497 | sigset_t *set, struct pt_regs *regs) | ||
498 | { | ||
499 | int usig = signr_convert(sig); | ||
500 | int ret; | ||
501 | |||
502 | /* Set up the stack frame */ | ||
503 | if (is_ia32) { | ||
504 | if (ka->sa.sa_flags & SA_SIGINFO) | ||
505 | ret = ia32_setup_rt_frame(usig, ka, info, set, regs); | ||
506 | else | ||
507 | ret = ia32_setup_frame(usig, ka, set, regs); | ||
508 | } else | ||
509 | ret = __setup_rt_frame(sig, ka, info, set, regs); | ||
510 | |||
511 | if (ret) { | ||
512 | force_sigsegv(sig, current); | ||
513 | return -EFAULT; | ||
514 | } | ||
515 | |||
516 | return ret; | ||
517 | } | ||
518 | |||
504 | static int | 519 | static int |
505 | handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | 520 | handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, |
506 | sigset_t *oldset, struct pt_regs *regs) | 521 | sigset_t *oldset, struct pt_regs *regs) |
@@ -508,9 +523,9 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | |||
508 | int ret; | 523 | int ret; |
509 | 524 | ||
510 | /* Are we from a system call? */ | 525 | /* Are we from a system call? */ |
511 | if ((long)regs->orig_ax >= 0) { | 526 | if (syscall_get_nr(current, regs) >= 0) { |
512 | /* If so, check system call restarting.. */ | 527 | /* If so, check system call restarting.. */ |
513 | switch (regs->ax) { | 528 | switch (syscall_get_error(current, regs)) { |
514 | case -ERESTART_RESTARTBLOCK: | 529 | case -ERESTART_RESTARTBLOCK: |
515 | case -ERESTARTNOHAND: | 530 | case -ERESTARTNOHAND: |
516 | regs->ax = -EINTR; | 531 | regs->ax = -EINTR; |
@@ -537,15 +552,20 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | |||
537 | likely(test_and_clear_thread_flag(TIF_FORCED_TF))) | 552 | likely(test_and_clear_thread_flag(TIF_FORCED_TF))) |
538 | regs->flags &= ~X86_EFLAGS_TF; | 553 | regs->flags &= ~X86_EFLAGS_TF; |
539 | 554 | ||
540 | /* Set up the stack frame */ | 555 | ret = setup_rt_frame(sig, ka, info, oldset, regs); |
541 | if (ka->sa.sa_flags & SA_SIGINFO) | ||
542 | ret = setup_rt_frame(sig, ka, info, oldset, regs); | ||
543 | else | ||
544 | ret = setup_frame(sig, ka, oldset, regs); | ||
545 | 556 | ||
546 | if (ret) | 557 | if (ret) |
547 | return ret; | 558 | return ret; |
548 | 559 | ||
560 | #ifdef CONFIG_X86_64 | ||
561 | /* | ||
562 | * This has nothing to do with segment registers, | ||
563 | * despite the name. This magic affects uaccess.h | ||
564 | * macros' behavior. Reset it to the normal setting. | ||
565 | */ | ||
566 | set_fs(USER_DS); | ||
567 | #endif | ||
568 | |||
549 | /* | 569 | /* |
550 | * Clear the direction flag as per the ABI for function entry. | 570 | * Clear the direction flag as per the ABI for function entry. |
551 | */ | 571 | */ |
@@ -558,8 +578,6 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | |||
558 | * handler too. | 578 | * handler too. |
559 | */ | 579 | */ |
560 | regs->flags &= ~X86_EFLAGS_TF; | 580 | regs->flags &= ~X86_EFLAGS_TF; |
561 | if (test_thread_flag(TIF_SINGLESTEP)) | ||
562 | ptrace_notify(SIGTRAP); | ||
563 | 581 | ||
564 | spin_lock_irq(¤t->sighand->siglock); | 582 | spin_lock_irq(¤t->sighand->siglock); |
565 | sigorsets(¤t->blocked, ¤t->blocked, &ka->sa.sa_mask); | 583 | sigorsets(¤t->blocked, ¤t->blocked, &ka->sa.sa_mask); |
@@ -568,9 +586,13 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | |||
568 | recalc_sigpending(); | 586 | recalc_sigpending(); |
569 | spin_unlock_irq(¤t->sighand->siglock); | 587 | spin_unlock_irq(¤t->sighand->siglock); |
570 | 588 | ||
589 | tracehook_signal_handler(sig, info, ka, regs, | ||
590 | test_thread_flag(TIF_SINGLESTEP)); | ||
591 | |||
571 | return 0; | 592 | return 0; |
572 | } | 593 | } |
573 | 594 | ||
595 | #define NR_restart_syscall __NR_restart_syscall | ||
574 | /* | 596 | /* |
575 | * Note that 'init' is a special process: it doesn't get signals it doesn't | 597 | * Note that 'init' is a special process: it doesn't get signals it doesn't |
576 | * want to handle. Thus you cannot kill init even with a SIGKILL even by | 598 | * want to handle. Thus you cannot kill init even with a SIGKILL even by |
@@ -623,9 +645,9 @@ static void do_signal(struct pt_regs *regs) | |||
623 | } | 645 | } |
624 | 646 | ||
625 | /* Did we come from a system call? */ | 647 | /* Did we come from a system call? */ |
626 | if ((long)regs->orig_ax >= 0) { | 648 | if (syscall_get_nr(current, regs) >= 0) { |
627 | /* Restart the system call - no handlers present */ | 649 | /* Restart the system call - no handlers present */ |
628 | switch (regs->ax) { | 650 | switch (syscall_get_error(current, regs)) { |
629 | case -ERESTARTNOHAND: | 651 | case -ERESTARTNOHAND: |
630 | case -ERESTARTSYS: | 652 | case -ERESTARTSYS: |
631 | case -ERESTARTNOINTR: | 653 | case -ERESTARTNOINTR: |
@@ -634,7 +656,7 @@ static void do_signal(struct pt_regs *regs) | |||
634 | break; | 656 | break; |
635 | 657 | ||
636 | case -ERESTART_RESTARTBLOCK: | 658 | case -ERESTART_RESTARTBLOCK: |
637 | regs->ax = __NR_restart_syscall; | 659 | regs->ax = NR_restart_syscall; |
638 | regs->ip -= 2; | 660 | regs->ip -= 2; |
639 | break; | 661 | break; |
640 | } | 662 | } |
@@ -657,9 +679,38 @@ static void do_signal(struct pt_regs *regs) | |||
657 | void | 679 | void |
658 | do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags) | 680 | do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags) |
659 | { | 681 | { |
682 | #if defined(CONFIG_X86_64) && defined(CONFIG_X86_MCE) | ||
683 | /* notify userspace of pending MCEs */ | ||
684 | if (thread_info_flags & _TIF_MCE_NOTIFY) | ||
685 | mce_notify_user(); | ||
686 | #endif /* CONFIG_X86_64 && CONFIG_X86_MCE */ | ||
687 | |||
660 | /* deal with pending signal delivery */ | 688 | /* deal with pending signal delivery */ |
661 | if (thread_info_flags & _TIF_SIGPENDING) | 689 | if (thread_info_flags & _TIF_SIGPENDING) |
662 | do_signal(regs); | 690 | do_signal(regs); |
663 | 691 | ||
692 | if (thread_info_flags & _TIF_NOTIFY_RESUME) { | ||
693 | clear_thread_flag(TIF_NOTIFY_RESUME); | ||
694 | tracehook_notify_resume(regs); | ||
695 | } | ||
696 | |||
697 | #ifdef CONFIG_X86_32 | ||
664 | clear_thread_flag(TIF_IRET); | 698 | clear_thread_flag(TIF_IRET); |
699 | #endif /* CONFIG_X86_32 */ | ||
700 | } | ||
701 | |||
702 | void signal_fault(struct pt_regs *regs, void __user *frame, char *where) | ||
703 | { | ||
704 | struct task_struct *me = current; | ||
705 | |||
706 | if (show_unhandled_signals && printk_ratelimit()) { | ||
707 | printk(KERN_INFO | ||
708 | "%s[%d] bad frame in %s frame:%p ip:%lx sp:%lx orax:%lx", | ||
709 | me->comm, me->pid, where, frame, | ||
710 | regs->ip, regs->sp, regs->orig_ax); | ||
711 | print_vma_addr(" in ", regs->ip); | ||
712 | printk(KERN_CONT "\n"); | ||
713 | } | ||
714 | |||
715 | force_sig(SIGSEGV, me); | ||
665 | } | 716 | } |