···215215}216216217217static int copy_sc_to_user(struct sigcontext __user *to,218218- struct _fpstate __user *to_fp, struct pt_regs *regs,219219- unsigned long sp)218218+ struct _fpstate __user *to_fp, struct pt_regs *regs)220219{221220 struct sigcontext sc;222221 struct faultinfo * fi = ¤t->thread.arch.faultinfo;···229230 sc.di = REGS_EDI(regs->regs.gp);230231 sc.si = REGS_ESI(regs->regs.gp);231232 sc.bp = REGS_EBP(regs->regs.gp);232232- sc.sp = sp;233233+ sc.sp = REGS_SP(regs->regs.gp);233234 sc.bx = REGS_EBX(regs->regs.gp);234235 sc.dx = REGS_EDX(regs->regs.gp);235236 sc.cx = REGS_ECX(regs->regs.gp);···290291 err |= put_user(current->sas_ss_sp, &uc->uc_stack.ss_sp);291292 err |= put_user(sas_ss_flags(sp), &uc->uc_stack.ss_flags);292293 err |= put_user(current->sas_ss_size, &uc->uc_stack.ss_size);293293- err |= copy_sc_to_user(&uc->uc_mcontext, fp, ¤t->thread.regs, sp);294294+ err |= copy_sc_to_user(&uc->uc_mcontext, fp, ¤t->thread.regs);294295 err |= copy_to_user(&uc->uc_sigmask, set, sizeof(*set));295296 return err;296297}···323324{324325 struct sigframe __user *frame;325326 void __user *restorer;326326- unsigned long save_sp = PT_REGS_SP(regs);327327 int err = 0;328328329329 /* This is the same calculation as i386 - ((sp + 4) & 15) == 0 */···335337 if (ka->sa.sa_flags & SA_RESTORER)336338 restorer = ka->sa.sa_restorer;337339338338- /* Update SP now because the page fault handler refuses to extend339339- * the stack if the faulting address is too far below the current340340- * SP, which frame now certainly is. If there's an error, the original341341- * value is restored on the way out.342342- * When writing the sigcontext to the stack, we have to write the343343- * original value, so that's passed to copy_sc_to_user, which does344344- * the right thing with it.345345- */346346- PT_REGS_SP(regs) = (unsigned long) frame;347347-348340 err |= __put_user(restorer, &frame->pretcode);349341 err |= __put_user(sig, &frame->sig);350350- err |= copy_sc_to_user(&frame->sc, NULL, regs, save_sp);342342+ err |= copy_sc_to_user(&frame->sc, NULL, regs);351343 err |= __put_user(mask->sig[0], &frame->sc.oldmask);352344 if (_NSIG_WORDS > 1)353345 err |= __copy_to_user(&frame->extramask, &mask->sig[1],···355367 err |= __put_user(0x80cd, (short __user *)(frame->retcode+6));356368357369 if (err)358358- goto err;370370+ return err;359371360372 PT_REGS_SP(regs) = (unsigned long) frame;361373 PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler;···366378 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED))367379 ptrace_notify(SIGTRAP);368380 return 0;369369-370370-err:371371- PT_REGS_SP(regs) = save_sp;372372- return err;373381}374382375383int setup_signal_stack_si(unsigned long stack_top, int sig,···374390{375391 struct rt_sigframe __user *frame;376392 void __user *restorer;377377- unsigned long save_sp = PT_REGS_SP(regs);378393 int err = 0;379394380395 stack_top &= -8UL;···385402 if (ka->sa.sa_flags & SA_RESTORER)386403 restorer = ka->sa.sa_restorer;387404388388- /* See comment above about why this is here */389389- PT_REGS_SP(regs) = (unsigned long) frame;390390-391405 err |= __put_user(restorer, &frame->pretcode);392406 err |= __put_user(sig, &frame->sig);393407 err |= __put_user(&frame->info, &frame->pinfo);394408 err |= __put_user(&frame->uc, &frame->puc);395409 err |= copy_siginfo_to_user(&frame->info, info);396410 err |= copy_ucontext_to_user(&frame->uc, &frame->fpstate, mask,397397- save_sp);411411+ PT_REGS_SP(regs));398412399413 /*400414 * This is movl $,%eax ; int $0x80···405425 err |= __put_user(0x80cd, (short __user *)(frame->retcode+5));406426407427 if (err)408408- goto err;428428+ return err;409429430430+ PT_REGS_SP(regs) = (unsigned long) frame;410431 PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler;411432 PT_REGS_EAX(regs) = (unsigned long) sig;412433 PT_REGS_EDX(regs) = (unsigned long) &frame->info;···416435 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED))417436 ptrace_notify(SIGTRAP);418437 return 0;419419-420420-err:421421- PT_REGS_SP(regs) = save_sp;422422- return err;423438}424439425440long sys_sigreturn(struct pt_regs regs)
+7-26
arch/x86/um/signal_64.c
···68686969static int copy_sc_to_user(struct sigcontext __user *to,7070 struct _fpstate __user *to_fp, struct pt_regs *regs,7171- unsigned long mask, unsigned long sp)7171+ unsigned long mask)7272{7373 struct faultinfo * fi = ¤t->thread.arch.faultinfo;7474 struct sigcontext sc;···8181 PUTREG(DI, di);8282 PUTREG(SI, si);8383 PUTREG(BP, bp);8484- /*8585- * Must use original RSP, which is passed in, rather than what's in8686- * signal frame.8787- */8888- sc.sp = sp;8484+ PUTREG(SP, sp);8985 PUTREG(BX, bx);9086 PUTREG(DX, dx);9187 PUTREG(CX, cx);···137141 siginfo_t *info, sigset_t *set)138142{139143 struct rt_sigframe __user *frame;140140- unsigned long save_sp = PT_REGS_RSP(regs);141144 int err = 0;142145 struct task_struct *me = current;143146···154159 goto out;155160 }156161157157- /*158158- * Update SP now because the page fault handler refuses to extend159159- * the stack if the faulting address is too far below the current160160- * SP, which frame now certainly is. If there's an error, the original161161- * value is restored on the way out.162162- * When writing the sigcontext to the stack, we have to write the163163- * original value, so that's passed to copy_sc_to_user, which does164164- * the right thing with it.165165- */166166- PT_REGS_RSP(regs) = (unsigned long) frame;167167-168162 /* Create the ucontext. */169163 err |= __put_user(0, &frame->uc.uc_flags);170164 err |= __put_user(0, &frame->uc.uc_link);171165 err |= __put_user(me->sas_ss_sp, &frame->uc.uc_stack.ss_sp);172172- err |= __put_user(sas_ss_flags(save_sp),166166+ err |= __put_user(sas_ss_flags(PT_REGS_RSP(regs)),173167 &frame->uc.uc_stack.ss_flags);174168 err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size);175169 err |= copy_sc_to_user(&frame->uc.uc_mcontext, &frame->fpstate, regs,176176- set->sig[0], save_sp);170170+ set->sig[0]);177171 err |= __put_user(&frame->fpstate, &frame->uc.uc_mcontext.fpstate);178172 if (sizeof(*set) == 16) {179173 __put_user(set->sig[0], &frame->uc.uc_sigmask.sig[0]);···181197 err |= __put_user(ka->sa.sa_restorer, &frame->pretcode);182198 else183199 /* could use a vstub here */184184- goto restore_sp;200200+ return err;185201186202 if (err)187187- goto restore_sp;203203+ return err;188204189205 /* Set up registers for signal handler */190206 {···193209 sig = ed->signal_invmap[sig];194210 }195211212212+ PT_REGS_RSP(regs) = (unsigned long) frame;196213 PT_REGS_RDI(regs) = sig;197214 /* In case the signal handler was declared without prototypes */198215 PT_REGS_RAX(regs) = 0;···206221 PT_REGS_RDX(regs) = (unsigned long) &frame->uc;207222 PT_REGS_RIP(regs) = (unsigned long) ka->sa.sa_handler;208223 out:209209- return err;210210-211211-restore_sp:212212- PT_REGS_RSP(regs) = save_sp;213224 return err;214225}215226