aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/signal_32.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-12-23 03:26:46 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2013-02-03 18:16:08 -0500
commit7cce246557bf379ea271d91f257ce248362cc12d (patch)
treea3c6c9c6f590990cbb1b3b6671b8c5e3fd1ff55a /arch/powerpc/kernel/signal_32.c
parent0aa0203fb43f04714004b2c4ad33b858e240555d (diff)
powerpc: switch to generic sigaltstack
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/powerpc/kernel/signal_32.c')
-rw-r--r--arch/powerpc/kernel/signal_32.c69
1 files changed, 8 insertions, 61 deletions
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index 9ec3fed3caac..0ea248c893cb 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -67,6 +67,8 @@
67#define mcontext mcontext32 67#define mcontext mcontext32
68#define ucontext ucontext32 68#define ucontext ucontext32
69 69
70#define __save_altstack __compat_save_altstack
71
70/* 72/*
71 * Userspace code may pass a ucontext which doesn't include VSX added 73 * Userspace code may pass a ucontext which doesn't include VSX added
72 * at the end. We need to check for this case. 74 * at the end. We need to check for this case.
@@ -763,55 +765,6 @@ long compat_sys_rt_sigqueueinfo(u32 pid, u32 sig, compat_siginfo_t __user *uinfo
763 set_fs (old_fs); 765 set_fs (old_fs);
764 return ret; 766 return ret;
765} 767}
766/*
767 * Start Alternate signal stack support
768 *
769 * System Calls
770 * sigaltatck compat_sys_sigaltstack
771 */
772
773int compat_sys_sigaltstack(u32 __new, u32 __old, int r5,
774 int r6, int r7, int r8, struct pt_regs *regs)
775{
776 stack_32_t __user * newstack = compat_ptr(__new);
777 stack_32_t __user * oldstack = compat_ptr(__old);
778 stack_t uss, uoss;
779 int ret;
780 mm_segment_t old_fs;
781 unsigned long sp;
782 compat_uptr_t ss_sp;
783
784 /*
785 * set sp to the user stack on entry to the system call
786 * the system call router sets R9 to the saved registers
787 */
788 sp = regs->gpr[1];
789
790 /* Put new stack info in local 64 bit stack struct */
791 if (newstack) {
792 if (get_user(ss_sp, &newstack->ss_sp) ||
793 __get_user(uss.ss_flags, &newstack->ss_flags) ||
794 __get_user(uss.ss_size, &newstack->ss_size))
795 return -EFAULT;
796 uss.ss_sp = compat_ptr(ss_sp);
797 }
798
799 old_fs = get_fs();
800 set_fs(KERNEL_DS);
801 /* The __user pointer casts are valid because of the set_fs() */
802 ret = do_sigaltstack(
803 newstack ? (stack_t __user *) &uss : NULL,
804 oldstack ? (stack_t __user *) &uoss : NULL,
805 sp);
806 set_fs(old_fs);
807 /* Copy the stack information to the user output buffer */
808 if (!ret && oldstack &&
809 (put_user(ptr_to_compat(uoss.ss_sp), &oldstack->ss_sp) ||
810 __put_user(uoss.ss_flags, &oldstack->ss_flags) ||
811 __put_user(uoss.ss_size, &oldstack->ss_size)))
812 return -EFAULT;
813 return ret;
814}
815#endif /* CONFIG_PPC64 */ 768#endif /* CONFIG_PPC64 */
816 769
817/* 770/*
@@ -838,10 +791,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
838 if (copy_siginfo_to_user(&rt_sf->info, info) 791 if (copy_siginfo_to_user(&rt_sf->info, info)
839 || __put_user(0, &rt_sf->uc.uc_flags) 792 || __put_user(0, &rt_sf->uc.uc_flags)
840 || __put_user(0, &rt_sf->uc.uc_link) 793 || __put_user(0, &rt_sf->uc.uc_link)
841 || __put_user(current->sas_ss_sp, &rt_sf->uc.uc_stack.ss_sp) 794 || __save_altstack(&rt_sf->uc.uc_stack, regs->gpr[1])
842 || __put_user(sas_ss_flags(regs->gpr[1]),
843 &rt_sf->uc.uc_stack.ss_flags)
844 || __put_user(current->sas_ss_size, &rt_sf->uc.uc_stack.ss_size)
845 || __put_user(to_user_ptr(&rt_sf->uc.uc_mcontext), 795 || __put_user(to_user_ptr(&rt_sf->uc.uc_mcontext),
846 &rt_sf->uc.uc_regs) 796 &rt_sf->uc.uc_regs)
847 || put_sigset_t(&rt_sf->uc.uc_sigmask, oldset)) 797 || put_sigset_t(&rt_sf->uc.uc_sigmask, oldset))
@@ -1038,14 +988,11 @@ long sys_rt_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8,
1038 * change it. -- paulus 988 * change it. -- paulus
1039 */ 989 */
1040#ifdef CONFIG_PPC64 990#ifdef CONFIG_PPC64
1041 /* 991 if (compat_restore_altstack(&rt_sf->uc.uc_stack))
1042 * We use the compat_sys_ version that does the 32/64 bits conversion 992 goto bad;
1043 * and takes userland pointer directly. What about error checking ?
1044 * nobody does any...
1045 */
1046 compat_sys_sigaltstack((u32)(u64)&rt_sf->uc.uc_stack, 0, 0, 0, 0, 0, regs);
1047#else 993#else
1048 do_sigaltstack(&rt_sf->uc.uc_stack, NULL, regs->gpr[1]); 994 if (restore_altstack(&rt_sf->uc.uc_stack))
995 goto bad;
1049#endif 996#endif
1050 set_thread_flag(TIF_RESTOREALL); 997 set_thread_flag(TIF_RESTOREALL);
1051 return 0; 998 return 0;
@@ -1161,7 +1108,7 @@ int sys_debug_setcontext(struct ucontext __user *ctx,
1161 * always done it up until now so it is probably better not to 1108 * always done it up until now so it is probably better not to
1162 * change it. -- paulus 1109 * change it. -- paulus
1163 */ 1110 */
1164 do_sigaltstack(&ctx->uc_stack, NULL, regs->gpr[1]); 1111 restore_altstack(&ctx->uc_stack);
1165 1112
1166 set_thread_flag(TIF_RESTOREALL); 1113 set_thread_flag(TIF_RESTOREALL);
1167 out: 1114 out: