diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-12-23 03:13:40 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-02-03 18:32:24 -0500 |
commit | ea536ad4f231a0055792d9b144715605cbd670c1 (patch) | |
tree | 31c7cd55f356cc80ba28b6e989e99af27fd2c567 /arch/mips/kernel/signal32.c | |
parent | c6489c147de592af4d0d1c5263e7b4f0e8e7d100 (diff) |
mips: switch to generic sigaltstack
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/mips/kernel/signal32.c')
-rw-r--r-- | arch/mips/kernel/signal32.c | 75 |
1 files changed, 3 insertions, 72 deletions
diff --git a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c index da1b56a39ac7..c51e5df4297b 100644 --- a/arch/mips/kernel/signal32.c +++ b/arch/mips/kernel/signal32.c | |||
@@ -61,17 +61,10 @@ struct sigaction32 { | |||
61 | compat_sigset_t sa_mask; | 61 | compat_sigset_t sa_mask; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | /* IRIX compatible stack_t */ | ||
65 | typedef struct sigaltstack32 { | ||
66 | s32 ss_sp; | ||
67 | compat_size_t ss_size; | ||
68 | int ss_flags; | ||
69 | } stack32_t; | ||
70 | |||
71 | struct ucontext32 { | 64 | struct ucontext32 { |
72 | u32 uc_flags; | 65 | u32 uc_flags; |
73 | s32 uc_link; | 66 | s32 uc_link; |
74 | stack32_t uc_stack; | 67 | compat_stack_t uc_stack; |
75 | struct sigcontext32 uc_mcontext; | 68 | struct sigcontext32 uc_mcontext; |
76 | compat_sigset_t uc_sigmask; /* mask last for extensibility */ | 69 | compat_sigset_t uc_sigmask; /* mask last for extensibility */ |
77 | }; | 70 | }; |
@@ -350,45 +343,6 @@ SYSCALL_DEFINE3(32_sigaction, long, sig, const struct sigaction32 __user *, act, | |||
350 | return ret; | 343 | return ret; |
351 | } | 344 | } |
352 | 345 | ||
353 | asmlinkage int sys32_sigaltstack(nabi_no_regargs struct pt_regs regs) | ||
354 | { | ||
355 | const stack32_t __user *uss = (const stack32_t __user *) regs.regs[4]; | ||
356 | stack32_t __user *uoss = (stack32_t __user *) regs.regs[5]; | ||
357 | unsigned long usp = regs.regs[29]; | ||
358 | stack_t kss, koss; | ||
359 | int ret, err = 0; | ||
360 | mm_segment_t old_fs = get_fs(); | ||
361 | s32 sp; | ||
362 | |||
363 | if (uss) { | ||
364 | if (!access_ok(VERIFY_READ, uss, sizeof(*uss))) | ||
365 | return -EFAULT; | ||
366 | err |= __get_user(sp, &uss->ss_sp); | ||
367 | kss.ss_sp = (void __user *) (long) sp; | ||
368 | err |= __get_user(kss.ss_size, &uss->ss_size); | ||
369 | err |= __get_user(kss.ss_flags, &uss->ss_flags); | ||
370 | if (err) | ||
371 | return -EFAULT; | ||
372 | } | ||
373 | |||
374 | set_fs(KERNEL_DS); | ||
375 | ret = do_sigaltstack(uss ? (stack_t __user *)&kss : NULL, | ||
376 | uoss ? (stack_t __user *)&koss : NULL, usp); | ||
377 | set_fs(old_fs); | ||
378 | |||
379 | if (!ret && uoss) { | ||
380 | if (!access_ok(VERIFY_WRITE, uoss, sizeof(*uoss))) | ||
381 | return -EFAULT; | ||
382 | sp = (int) (unsigned long) koss.ss_sp; | ||
383 | err |= __put_user(sp, &uoss->ss_sp); | ||
384 | err |= __put_user(koss.ss_size, &uoss->ss_size); | ||
385 | err |= __put_user(koss.ss_flags, &uoss->ss_flags); | ||
386 | if (err) | ||
387 | return -EFAULT; | ||
388 | } | ||
389 | return ret; | ||
390 | } | ||
391 | |||
392 | int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from) | 346 | int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from) |
393 | { | 347 | { |
394 | int err; | 348 | int err; |
@@ -490,10 +444,7 @@ badframe: | |||
490 | asmlinkage void sys32_rt_sigreturn(nabi_no_regargs struct pt_regs regs) | 444 | asmlinkage void sys32_rt_sigreturn(nabi_no_regargs struct pt_regs regs) |
491 | { | 445 | { |
492 | struct rt_sigframe32 __user *frame; | 446 | struct rt_sigframe32 __user *frame; |
493 | mm_segment_t old_fs; | ||
494 | sigset_t set; | 447 | sigset_t set; |
495 | stack_t st; | ||
496 | s32 sp; | ||
497 | int sig; | 448 | int sig; |
498 | 449 | ||
499 | frame = (struct rt_sigframe32 __user *) regs.regs[29]; | 450 | frame = (struct rt_sigframe32 __user *) regs.regs[29]; |
@@ -510,22 +461,9 @@ asmlinkage void sys32_rt_sigreturn(nabi_no_regargs struct pt_regs regs) | |||
510 | else if (sig) | 461 | else if (sig) |
511 | force_sig(sig, current); | 462 | force_sig(sig, current); |
512 | 463 | ||
513 | /* The ucontext contains a stack32_t, so we must convert! */ | 464 | if (compat_restore_altstack(&frame->rs_uc.uc_stack)) |
514 | if (__get_user(sp, &frame->rs_uc.uc_stack.ss_sp)) | ||
515 | goto badframe; | ||
516 | st.ss_sp = (void __user *)(long) sp; | ||
517 | if (__get_user(st.ss_size, &frame->rs_uc.uc_stack.ss_size)) | ||
518 | goto badframe; | ||
519 | if (__get_user(st.ss_flags, &frame->rs_uc.uc_stack.ss_flags)) | ||
520 | goto badframe; | 465 | goto badframe; |
521 | 466 | ||
522 | /* It is more difficult to avoid calling this function than to | ||
523 | call it and ignore errors. */ | ||
524 | old_fs = get_fs(); | ||
525 | set_fs(KERNEL_DS); | ||
526 | do_sigaltstack((stack_t __user *)&st, NULL, regs.regs[29]); | ||
527 | set_fs(old_fs); | ||
528 | |||
529 | /* | 467 | /* |
530 | * Don't let your children do this ... | 468 | * Don't let your children do this ... |
531 | */ | 469 | */ |
@@ -590,7 +528,6 @@ static int setup_rt_frame_32(void *sig_return, struct k_sigaction *ka, | |||
590 | { | 528 | { |
591 | struct rt_sigframe32 __user *frame; | 529 | struct rt_sigframe32 __user *frame; |
592 | int err = 0; | 530 | int err = 0; |
593 | s32 sp; | ||
594 | 531 | ||
595 | frame = get_sigframe(ka, regs, sizeof(*frame)); | 532 | frame = get_sigframe(ka, regs, sizeof(*frame)); |
596 | if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) | 533 | if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame))) |
@@ -602,13 +539,7 @@ static int setup_rt_frame_32(void *sig_return, struct k_sigaction *ka, | |||
602 | /* Create the ucontext. */ | 539 | /* Create the ucontext. */ |
603 | err |= __put_user(0, &frame->rs_uc.uc_flags); | 540 | err |= __put_user(0, &frame->rs_uc.uc_flags); |
604 | err |= __put_user(0, &frame->rs_uc.uc_link); | 541 | err |= __put_user(0, &frame->rs_uc.uc_link); |
605 | sp = (int) (long) current->sas_ss_sp; | 542 | err |= __compat_save_altstack(&frame->rs_uc.uc_stack, regs->regs[29]); |
606 | err |= __put_user(sp, | ||
607 | &frame->rs_uc.uc_stack.ss_sp); | ||
608 | err |= __put_user(sas_ss_flags(regs->regs[29]), | ||
609 | &frame->rs_uc.uc_stack.ss_flags); | ||
610 | err |= __put_user(current->sas_ss_size, | ||
611 | &frame->rs_uc.uc_stack.ss_size); | ||
612 | err |= setup_sigcontext32(regs, &frame->rs_uc.uc_mcontext); | 543 | err |= setup_sigcontext32(regs, &frame->rs_uc.uc_mcontext); |
613 | err |= __copy_conv_sigset_to_user(&frame->rs_uc.uc_sigmask, set); | 544 | err |= __copy_conv_sigset_to_user(&frame->rs_uc.uc_sigmask, set); |
614 | 545 | ||