aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-05-10 20:58:00 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-05-21 23:52:35 -0400
commitf3b5e822739c70663aee8584b7993afe055431c9 (patch)
tree4a28ae3af58dfdceefa590136a0e0ea4a6a191c0
parent7a076e4ff07ffc2c219285ec57aed8bdde86cb37 (diff)
cris: use set_current_blocked() and block_sigmask()
As described in e6fa16ab ("signal: sigprocmask() should do retarget_shared_pending()") the modification of current->blocked is incorrect as we need to check whether the signal we're about to block is pending in the shared queue. Also, use the new helper function introduced in commit 5e6292c0f28f ("signal: add block_sigmask() for adding sigmask to current->blocked") which centralises the code for updating current->blocked after successfully delivering a signal and reduces the amount of duplicate code across architectures. In the past some architectures got this code wrong, so using this helper function should stop that from happening again. Acked-by: Oleg Nesterov <oleg@redhat.com> Cc: Mikael Starvik <starvik@axis.com> Acked-by: Jesper Nilsson <jesper.nilsson@axis.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--arch/cris/arch-v10/kernel/signal.c22
-rw-r--r--arch/cris/arch-v32/kernel/signal.c25
2 files changed, 9 insertions, 38 deletions
diff --git a/arch/cris/arch-v10/kernel/signal.c b/arch/cris/arch-v10/kernel/signal.c
index 170f4970d590..df40fa80480f 100644
--- a/arch/cris/arch-v10/kernel/signal.c
+++ b/arch/cris/arch-v10/kernel/signal.c
@@ -177,10 +177,7 @@ asmlinkage int sys_sigreturn(long r10, long r11, long r12, long r13, long mof,
177 goto badframe; 177 goto badframe;
178 178
179 sigdelsetmask(&set, ~_BLOCKABLE); 179 sigdelsetmask(&set, ~_BLOCKABLE);
180 spin_lock_irq(&current->sighand->siglock); 180 set_current_blocked(&set);
181 current->blocked = set;
182 recalc_sigpending();
183 spin_unlock_irq(&current->sighand->siglock);
184 181
185 if (restore_sigcontext(regs, &frame->sc)) 182 if (restore_sigcontext(regs, &frame->sc))
186 goto badframe; 183 goto badframe;
@@ -216,10 +213,7 @@ asmlinkage int sys_rt_sigreturn(long r10, long r11, long r12, long r13,
216 goto badframe; 213 goto badframe;
217 214
218 sigdelsetmask(&set, ~_BLOCKABLE); 215 sigdelsetmask(&set, ~_BLOCKABLE);
219 spin_lock_irq(&current->sighand->siglock); 216 set_current_blocked(&set);
220 current->blocked = set;
221 recalc_sigpending();
222 spin_unlock_irq(&current->sighand->siglock);
223 217
224 if (restore_sigcontext(regs, &frame->uc.uc_mcontext)) 218 if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
225 goto badframe; 219 goto badframe;
@@ -461,15 +455,9 @@ static inline int handle_signal(int canrestart, unsigned long sig,
461 else 455 else
462 ret = setup_frame(sig, ka, oldset, regs); 456 ret = setup_frame(sig, ka, oldset, regs);
463 457
464 if (ret == 0) { 458 if (ret == 0)
465 spin_lock_irq(&current->sighand->siglock); 459 block_sigmask(ka, sig);
466 sigorsets(&current->blocked, &current->blocked, 460
467 &ka->sa.sa_mask);
468 if (!(ka->sa.sa_flags & SA_NODEFER))
469 sigaddset(&current->blocked, sig);
470 recalc_sigpending();
471 spin_unlock_irq(&current->sighand->siglock);
472 }
473 return ret; 461 return ret;
474} 462}
475 463
diff --git a/arch/cris/arch-v32/kernel/signal.c b/arch/cris/arch-v32/kernel/signal.c
index e09083208cb6..b0a6cf4f2cad 100644
--- a/arch/cris/arch-v32/kernel/signal.c
+++ b/arch/cris/arch-v32/kernel/signal.c
@@ -168,12 +168,7 @@ sys_sigreturn(long r10, long r11, long r12, long r13, long mof, long srp,
168 goto badframe; 168 goto badframe;
169 169
170 sigdelsetmask(&set, ~_BLOCKABLE); 170 sigdelsetmask(&set, ~_BLOCKABLE);
171 spin_lock_irq(&current->sighand->siglock); 171 set_current_blocked(&set);
172
173 current->blocked = set;
174
175 recalc_sigpending();
176 spin_unlock_irq(&current->sighand->siglock);
177 172
178 if (restore_sigcontext(regs, &frame->sc)) 173 if (restore_sigcontext(regs, &frame->sc))
179 goto badframe; 174 goto badframe;
@@ -214,12 +209,7 @@ sys_rt_sigreturn(long r10, long r11, long r12, long r13, long mof, long srp,
214 goto badframe; 209 goto badframe;
215 210
216 sigdelsetmask(&set, ~_BLOCKABLE); 211 sigdelsetmask(&set, ~_BLOCKABLE);
217 spin_lock_irq(&current->sighand->siglock); 212 set_current_blocked(&set);
218
219 current->blocked = set;
220
221 recalc_sigpending();
222 spin_unlock_irq(&current->sighand->siglock);
223 213
224 if (restore_sigcontext(regs, &frame->uc.uc_mcontext)) 214 if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
225 goto badframe; 215 goto badframe;
@@ -507,15 +497,8 @@ handle_signal(int canrestart, unsigned long sig,
507 if (ka->sa.sa_flags & SA_ONESHOT) 497 if (ka->sa.sa_flags & SA_ONESHOT)
508 ka->sa.sa_handler = SIG_DFL; 498 ka->sa.sa_handler = SIG_DFL;
509 499
510 if (ret == 0) { 500 if (ret == 0)
511 spin_lock_irq(&current->sighand->siglock); 501 block_sigmask(ka, sig);
512 sigorsets(&current->blocked, &current->blocked,
513 &ka->sa.sa_mask);
514 if (!(ka->sa.sa_flags & SA_NODEFER))
515 sigaddset(&current->blocked, sig);
516 recalc_sigpending();
517 spin_unlock_irq(&current->sighand->siglock);
518 }
519 502
520 return ret; 503 return ret;
521} 504}