aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-11-20 14:24:26 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2012-12-19 18:07:41 -0500
commitc40702c49faef05ae324f121d8b3e215244ee152 (patch)
treeb0b2a51b07e944497da5cb48fb461963a3762cad /arch/x86
parent9026843952adac5b123c7b8dc961e5c15828d9e1 (diff)
new helpers: __save_altstack/__compat_save_altstack, switch x86 and um to those
note that they are relying on access_ok() already checked by caller. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/ia32/ia32_signal.c5
-rw-r--r--arch/x86/kernel/signal.c18
-rw-r--r--arch/x86/um/signal.c9
3 files changed, 7 insertions, 25 deletions
diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index a866411a2fcc..a1daf4a65009 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -467,10 +467,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
467 else 467 else
468 put_user_ex(0, &frame->uc.uc_flags); 468 put_user_ex(0, &frame->uc.uc_flags);
469 put_user_ex(0, &frame->uc.uc_link); 469 put_user_ex(0, &frame->uc.uc_link);
470 put_user_ex(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); 470 err |= __compat_save_altstack(&frame->uc.uc_stack, regs->sp);
471 put_user_ex(sas_ss_flags(regs->sp),
472 &frame->uc.uc_stack.ss_flags);
473 put_user_ex(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
474 471
475 if (ka->sa.sa_flags & SA_RESTORER) 472 if (ka->sa.sa_flags & SA_RESTORER)
476 restorer = ka->sa.sa_restorer; 473 restorer = ka->sa.sa_restorer;
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index b17ed37c61a2..a6c8a347b8c6 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -363,10 +363,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
363 else 363 else
364 put_user_ex(0, &frame->uc.uc_flags); 364 put_user_ex(0, &frame->uc.uc_flags);
365 put_user_ex(0, &frame->uc.uc_link); 365 put_user_ex(0, &frame->uc.uc_link);
366 put_user_ex(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); 366 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
367 put_user_ex(sas_ss_flags(regs->sp),
368 &frame->uc.uc_stack.ss_flags);
369 put_user_ex(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
370 367
371 /* Set up to return from userspace. */ 368 /* Set up to return from userspace. */
372 restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn); 369 restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
@@ -413,7 +410,6 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
413 struct rt_sigframe __user *frame; 410 struct rt_sigframe __user *frame;
414 void __user *fp = NULL; 411 void __user *fp = NULL;
415 int err = 0; 412 int err = 0;
416 struct task_struct *me = current;
417 413
418 frame = get_sigframe(ka, regs, sizeof(struct rt_sigframe), &fp); 414 frame = get_sigframe(ka, regs, sizeof(struct rt_sigframe), &fp);
419 415
@@ -432,10 +428,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
432 else 428 else
433 put_user_ex(0, &frame->uc.uc_flags); 429 put_user_ex(0, &frame->uc.uc_flags);
434 put_user_ex(0, &frame->uc.uc_link); 430 put_user_ex(0, &frame->uc.uc_link);
435 put_user_ex(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp); 431 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
436 put_user_ex(sas_ss_flags(regs->sp),
437 &frame->uc.uc_stack.ss_flags);
438 put_user_ex(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
439 432
440 /* Set up to return from userspace. If provided, use a stub 433 /* Set up to return from userspace. If provided, use a stub
441 already in userspace. */ 434 already in userspace. */
@@ -502,10 +495,7 @@ static int x32_setup_rt_frame(int sig, struct k_sigaction *ka,
502 else 495 else
503 put_user_ex(0, &frame->uc.uc_flags); 496 put_user_ex(0, &frame->uc.uc_flags);
504 put_user_ex(0, &frame->uc.uc_link); 497 put_user_ex(0, &frame->uc.uc_link);
505 put_user_ex(current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); 498 err |= __compat_save_altstack(&frame->uc.uc_stack, regs->sp);
506 put_user_ex(sas_ss_flags(regs->sp),
507 &frame->uc.uc_stack.ss_flags);
508 put_user_ex(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
509 put_user_ex(0, &frame->uc.uc__pad0); 499 put_user_ex(0, &frame->uc.uc__pad0);
510 500
511 if (ka->sa.sa_flags & SA_RESTORER) { 501 if (ka->sa.sa_flags & SA_RESTORER) {
@@ -651,7 +641,7 @@ long sys_rt_sigreturn(struct pt_regs *regs)
651 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax)) 641 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ax))
652 goto badframe; 642 goto badframe;
653 643
654 if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT) 644 if (restore_altstack(&frame->uc.uc_stack))
655 goto badframe; 645 goto badframe;
656 646
657 return ax; 647 return ax;
diff --git a/arch/x86/um/signal.c b/arch/x86/um/signal.c
index bdaa08cfbcf4..71cef48ea5cd 100644
--- a/arch/x86/um/signal.c
+++ b/arch/x86/um/signal.c
@@ -342,9 +342,7 @@ static int copy_ucontext_to_user(struct ucontext __user *uc,
342{ 342{
343 int err = 0; 343 int err = 0;
344 344
345 err |= put_user(current->sas_ss_sp, &uc->uc_stack.ss_sp); 345 err |= __save_altstack(&uc->uc_stack, sp);
346 err |= put_user(sas_ss_flags(sp), &uc->uc_stack.ss_flags);
347 err |= put_user(current->sas_ss_size, &uc->uc_stack.ss_size);
348 err |= copy_sc_to_user(&uc->uc_mcontext, fp, &current->thread.regs, 0); 346 err |= copy_sc_to_user(&uc->uc_mcontext, fp, &current->thread.regs, 0);
349 err |= copy_to_user(&uc->uc_sigmask, set, sizeof(*set)); 347 err |= copy_to_user(&uc->uc_sigmask, set, sizeof(*set));
350 return err; 348 return err;
@@ -529,10 +527,7 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
529 /* Create the ucontext. */ 527 /* Create the ucontext. */
530 err |= __put_user(0, &frame->uc.uc_flags); 528 err |= __put_user(0, &frame->uc.uc_flags);
531 err |= __put_user(0, &frame->uc.uc_link); 529 err |= __put_user(0, &frame->uc.uc_link);
532 err |= __put_user(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp); 530 err |= __save_altstack(&frame->uc.uc_stack, PT_REGS_SP(regs));
533 err |= __put_user(sas_ss_flags(PT_REGS_SP(regs)),
534 &frame->uc.uc_stack.ss_flags);
535 err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
536 err |= copy_sc_to_user(&frame->uc.uc_mcontext, &frame->fpstate, regs, 531 err |= copy_sc_to_user(&frame->uc.uc_mcontext, &frame->fpstate, regs,
537 set->sig[0]); 532 set->sig[0]);
538 err |= __put_user(&frame->fpstate, &frame->uc.uc_mcontext.fpstate); 533 err |= __put_user(&frame->fpstate, &frame->uc.uc_mcontext.fpstate);