pPC64 signal race fix patch
PATCH 7/8 pPC64 signal race fix patch
From: Paul Mackerras <[email protected]>
Compile-tested, but not boot-tested since I am still travelling.
Signed-off-by Paul Mackerras <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
25-akpm/arch/ppc64/kernel/signal.c | 45 +++++++++++++++++------------------ 25-akpm/arch/ppc64/kernel/signal32.c | 38 +++++++++++++---------------- 2 files changed, 39 insertions(+), 44 deletions(-)
arch/ppc64/kernel/signal32.c renamed from arch/ppc64/kernel/signal32.c~signal-race-fixes-ppc64 +17 -21
@@ -641,7 +641,7 @@ int sys32_sigaltstack(u32 __new, u32 __o* Set up a signal frame for a "real-time" signal handler * (one which gets siginfo). */ -static void handle_rt_signal32 (unsigned long sig,struct k_sigaction *ka, +static void handle_rt_signal32 (unsigned long sig,struct k_sigaction *ka_copy,siginfo_t *info,sigset_t *oldset,struct pt_regs * regs,unsigned long newsp) {
@@ -687,7 +687,7 @@ static void handle_rt_signal32(unsigned regs->gpr[4 ] = (unsigned long ) &rt_sf->info; regs->gpr[5 ] = (unsigned long ) &rt_sf->uc; regs->gpr[6 ] = (unsigned long ) rt_sf; - regs->nip = (unsigned long ) ka->sa.sa_handler; + regs->nip = (unsigned long ) ka_copy->sa.sa_handler; regs->link = (unsigned long ) frame->tramp; regs->trap =0 ; regs->result =0 ;
@@ -700,7 +700,7 @@ badframe: regs, frame, newsp);#endif if (sig ==SIGSEGV ) - ka->sa.sa_handler =SIG_DFL ; + current->sighand->action[SIGSEGV -1 ].sa.sa_handler =SIG_DFL ;force_sig (SIGSEGV , current); }
@@ -812,7 +812,7 @@ long sys32_rt_sigreturn(int r3, int r4,/* * OK, we're invoking a handler */ -static void handle_signal32 (unsigned long sig,struct k_sigaction *ka, +static void handle_signal32 (unsigned long sig,struct k_sigaction *ka_copy,siginfo_t *info,sigset_t *oldset,struct pt_regs * regs,unsigned long newsp) {
@@ -837,7 +837,7 @@ static void handle_signal32(unsigned lon#if _NSIG !=64 #error "Please adjust handle_signal32()"#endif -if (__put_user ((u32 )(u64 )ka->sa.sa_handler, &sc->handler) +if (__put_user ((u32 )(u64 )ka_copy->sa.sa_handler, &sc->handler) ||__put_user (oldset->sig[0 ], &sc->oldmask) ||__put_user ((oldset->sig[0 ] >>32 ), &sc->_unused[3 ]) || __put_user((u32)(u64)frame, &sc->regs)
@@ -852,7 +852,7 @@ static void handle_signal32(unsigned lon regs->gpr[1 ] = (unsigned long ) newsp; regs->gpr[3 ] = sig; regs->gpr[4 ] = (unsigned long ) sc; - regs->nip = (unsigned long ) ka->sa.sa_handler; + regs->nip = (unsigned long ) ka_copy->sa.sa_handler; regs->link = (unsigned long ) frame->mctx.tramp; regs->trap =0 ; regs->result =0 ;
@@ -865,7 +865,7 @@ badframe: regs, frame, *newspp);#endif if (sig ==SIGSEGV ) - ka->sa.sa_handler =SIG_DFL ; + current->sighand->action[SIGSEGV -1 ].sa.sa_handler =SIG_DFL ;force_sig (SIGSEGV , current); }
@@ -928,18 +928,16 @@ badframe:int do_signal32 (sigset_t *oldset,struct pt_regs *regs) {siginfo_t info; -struct k_sigaction *ka;unsigned int frame, newsp;int signr, ret; +struct k_sigaction ka_copy;if (!oldset) oldset = ¤t->blocked; newsp = frame =0 ; - signr =get_signal_to_deliver (&info, regs,NULL ); - - ka = (signr ==0 )?NULL : ¤t->sighand->action[signr-1 ]; + signr =get_signal_to_deliver (&info, &ka_copy, regs,NULL );if (TRAP (regs) ==0x0C00 /* System Call! */ && regs->ccr & 0x10000000 /* error signalled */
@@ -950,7 +948,7 @@ int do_signal32(sigset_t *oldset, structif (signr >0 && (ret ==ERESTARTNOHAND || ret ==ERESTART_RESTARTBLOCK || (ret ==ERESTARTSYS - && !(ka->sa.sa_flags &SA_RESTART )))) { + && !(ka_copy.sa.sa_flags &SA_RESTART )))) {/* make the system call return an EINTR error */ regs->result = -EINTR ; regs->gpr[3 ] =EINTR ;
@@ -969,7 +967,7 @@ int do_signal32(sigset_t *oldset, structif (signr ==0 )return 0 ;/* no signals delivered */ -if ((ka->sa.sa_flags &SA_ONSTACK ) && current->sas_ss_size +if ((ka_copy.sa.sa_flags &SA_ONSTACK ) && current->sas_ss_size && (!on_sig_stack (regs->gpr[1 ]))) newsp = (current->sas_ss_sp + current->sas_ss_size);else
@@ -977,17 +975,15 @@ int do_signal32(sigset_t *oldset, struct newsp &= ~0xfUL ;/* Whee! Actually deliver the signal. */ -if (ka->sa.sa_flags &SA_SIGINFO ) -handle_rt_signal32 (signr, ka, &info, oldset, regs, newsp); +if (ka_copy.sa.sa_flags &SA_SIGINFO ) +handle_rt_signal32 (signr, &ka_copy, &info, oldset, regs, newsp);else -handle_signal32 (signr, ka, &info, oldset, regs, newsp); - -if (ka->sa.sa_flags &SA_ONESHOT ) - ka->sa.sa_handler =SIG_DFL ; +handle_signal32 (signr, &ka_copy, &info, oldset, regs, newsp); -if (!(ka->sa.sa_flags &SA_NODEFER )) { +if (!(ka_copy.sa.sa_flags &SA_NODEFER )) {spin_lock_irq (¤t->sighand->siglock); -sigorsets (¤t->blocked,¤t->blocked,&ka->sa.sa_mask); +sigorsets (¤t->blocked, ¤t->blocked, + &ka_copy.sa.sa_mask);sigaddset (¤t->blocked, signr);recalc_sigpending ();spin_unlock_irq (¤t->sighand->siglock);
arch/ppc64/kernel/signal.c renamed from arch/ppc64/kernel/signal.c~signal-race-fixes-ppc64 +22 -23
118 lines not on this page · raw message
_