aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/signal_32.c
diff options
context:
space:
mode:
authorHiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>2008-09-12 20:01:09 -0400
committerIngo Molnar <mingo@elte.hu>2008-09-14 09:35:34 -0400
commit3d0aedd9538e6be8afec1a9d8b084bf90bc91495 (patch)
treef1dd505b2a703343a0c5dc0ab3a7c2e98949f1f8 /arch/x86/kernel/signal_32.c
parent764e8d128f9343027cf09afe8a145e8ff186e129 (diff)
x86: signal: put give_sigsegv of setup frames together
When setup frame fails, force_sigsegv is called and returns -EFAULT. There is similar code in ia32_setup_frame(), ia32_setup_rt_frame(), __setup_frame() and __setup_rt_frame(). Make them identical. No change in functionality intended. Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/signal_32.c')
-rw-r--r--arch/x86/kernel/signal_32.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c
index b668efc18eae..1c22e0067fe7 100644
--- a/arch/x86/kernel/signal_32.c
+++ b/arch/x86/kernel/signal_32.c
@@ -349,21 +349,21 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
349 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate); 349 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
350 350
351 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) 351 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
352 goto give_sigsegv; 352 return -EFAULT;
353 353
354 err = __put_user(sig, &frame->sig); 354 err = __put_user(sig, &frame->sig);
355 if (err) 355 if (err)
356 goto give_sigsegv; 356 return -EFAULT;
357 357
358 err = setup_sigcontext(&frame->sc, fpstate, regs, set->sig[0]); 358 err = setup_sigcontext(&frame->sc, fpstate, regs, set->sig[0]);
359 if (err) 359 if (err)
360 goto give_sigsegv; 360 return -EFAULT;
361 361
362 if (_NSIG_WORDS > 1) { 362 if (_NSIG_WORDS > 1) {
363 err = __copy_to_user(&frame->extramask, &set->sig[1], 363 err = __copy_to_user(&frame->extramask, &set->sig[1],
364 sizeof(frame->extramask)); 364 sizeof(frame->extramask));
365 if (err) 365 if (err)
366 goto give_sigsegv; 366 return -EFAULT;
367 } 367 }
368 368
369 if (current->mm->context.vdso) 369 if (current->mm->context.vdso)
@@ -388,7 +388,7 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
388 err |= __put_user(0x80cd, (short __user *)(frame->retcode+6)); 388 err |= __put_user(0x80cd, (short __user *)(frame->retcode+6));
389 389
390 if (err) 390 if (err)
391 goto give_sigsegv; 391 return -EFAULT;
392 392
393 /* Set up registers for signal handler */ 393 /* Set up registers for signal handler */
394 regs->sp = (unsigned long)frame; 394 regs->sp = (unsigned long)frame;
@@ -403,10 +403,6 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
403 regs->cs = __USER_CS; 403 regs->cs = __USER_CS;
404 404
405 return 0; 405 return 0;
406
407give_sigsegv:
408 force_sigsegv(sig, current);
409 return -EFAULT;
410} 406}
411 407
412static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, 408static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
@@ -420,14 +416,14 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
420 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate); 416 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
421 417
422 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) 418 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
423 goto give_sigsegv; 419 return -EFAULT;
424 420
425 err |= __put_user(sig, &frame->sig); 421 err |= __put_user(sig, &frame->sig);
426 err |= __put_user(&frame->info, &frame->pinfo); 422 err |= __put_user(&frame->info, &frame->pinfo);
427 err |= __put_user(&frame->uc, &frame->puc); 423 err |= __put_user(&frame->uc, &frame->puc);
428 err |= copy_siginfo_to_user(&frame->info, info); 424 err |= copy_siginfo_to_user(&frame->info, info);
429 if (err) 425 if (err)
430 goto give_sigsegv; 426 return -EFAULT;
431 427
432 /* Create the ucontext. */ 428 /* Create the ucontext. */
433 if (cpu_has_xsave) 429 if (cpu_has_xsave)
@@ -443,7 +439,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
443 regs, set->sig[0]); 439 regs, set->sig[0]);
444 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set)); 440 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
445 if (err) 441 if (err)
446 goto give_sigsegv; 442 return -EFAULT;
447 443
448 /* Set up to return from userspace. */ 444 /* Set up to return from userspace. */
449 restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn); 445 restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
@@ -463,7 +459,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
463 err |= __put_user(0x80cd, (short __user *)(frame->retcode+5)); 459 err |= __put_user(0x80cd, (short __user *)(frame->retcode+5));
464 460
465 if (err) 461 if (err)
466 goto give_sigsegv; 462 return -EFAULT;
467 463
468 /* Set up registers for signal handler */ 464 /* Set up registers for signal handler */
469 regs->sp = (unsigned long)frame; 465 regs->sp = (unsigned long)frame;
@@ -478,10 +474,6 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
478 regs->cs = __USER_CS; 474 regs->cs = __USER_CS;
479 475
480 return 0; 476 return 0;
481
482give_sigsegv:
483 force_sigsegv(sig, current);
484 return -EFAULT;
485} 477}
486 478
487/* 479/*
@@ -506,6 +498,11 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
506 else 498 else
507 ret = __setup_frame(usig, ka, set, regs); 499 ret = __setup_frame(usig, ka, set, regs);
508 500
501 if (ret) {
502 force_sigsegv(sig, current);
503 return -EFAULT;
504 }
505
509 return ret; 506 return ret;
510} 507}
511 508