aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-05-02 09:59:21 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-06-01 12:58:48 -0400
commitb7f9a11a6cf1ea9ee6be3eb2b90d91327a09ad14 (patch)
tree7d5a5f469aea8ac2b3e1ab41e05a6abafcb2b694 /arch
parent51a7b448d4134e3e8eec633435e3e8faee14a828 (diff)
new helper: sigmask_to_save()
replace boilerplate "should we use ->saved_sigmask or ->blocked?" with calls of obvious inlined helper... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r--arch/alpha/kernel/signal.c5
-rw-r--r--arch/arm/kernel/signal.c12
-rw-r--r--arch/avr32/kernel/signal.c20
-rw-r--r--arch/blackfin/kernel/signal.c12
-rw-r--r--arch/c6x/kernel/signal.c14
-rw-r--r--arch/cris/arch-v10/kernel/signal.c11
-rw-r--r--arch/cris/arch-v32/kernel/signal.c11
-rw-r--r--arch/frv/kernel/signal.c10
-rw-r--r--arch/h8300/kernel/signal.c11
-rw-r--r--arch/hexagon/kernel/signal.c13
-rw-r--r--arch/ia64/kernel/signal.c12
-rw-r--r--arch/m32r/kernel/signal.c12
-rw-r--r--arch/m68k/kernel/signal.c11
-rw-r--r--arch/microblaze/kernel/signal.c9
-rw-r--r--arch/mips/kernel/signal.c11
-rw-r--r--arch/mn10300/kernel/signal.c11
-rw-r--r--arch/openrisc/kernel/signal.c12
-rw-r--r--arch/parisc/kernel/signal.c21
-rw-r--r--arch/powerpc/kernel/signal.c7
-rw-r--r--arch/s390/kernel/signal.c7
-rw-r--r--arch/score/kernel/signal.c12
-rw-r--r--arch/sh/kernel/signal_32.c11
-rw-r--r--arch/sh/kernel/signal_64.c13
-rw-r--r--arch/sparc/kernel/signal_32.c11
-rw-r--r--arch/sparc/kernel/signal_64.c7
-rw-r--r--arch/tile/kernel/signal.c11
-rw-r--r--arch/um/kernel/signal.c11
-rw-r--r--arch/unicore32/kernel/signal.c13
-rw-r--r--arch/x86/kernel/signal.c5
-rw-r--r--arch/xtensa/kernel/signal.c8
30 files changed, 84 insertions, 250 deletions
diff --git a/arch/alpha/kernel/signal.c b/arch/alpha/kernel/signal.c
index cadf4571ca31..f1e7d2aa2586 100644
--- a/arch/alpha/kernel/signal.c
+++ b/arch/alpha/kernel/signal.c
@@ -468,12 +468,9 @@ static inline void
468handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info, 468handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
469 struct pt_regs * regs, struct switch_stack *sw) 469 struct pt_regs * regs, struct switch_stack *sw)
470{ 470{
471 sigset_t *oldset = &current->blocked; 471 sigset_t *oldset = sigmask_to_save();
472 int ret; 472 int ret;
473 473
474 if (test_thread_flag(TIF_RESTORE_SIGMASK))
475 oldset = &current->saved_sigmask;
476
477 if (ka->sa.sa_flags & SA_SIGINFO) 474 if (ka->sa.sa_flags & SA_SIGINFO)
478 ret = setup_rt_frame(sig, ka, info, oldset, regs, sw); 475 ret = setup_rt_frame(sig, ka, info, oldset, regs, sw);
479 else 476 else
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index 3d1daac8ea04..2e66c93973c3 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -530,11 +530,11 @@ setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
530 */ 530 */
531static int 531static int
532handle_signal(unsigned long sig, struct k_sigaction *ka, 532handle_signal(unsigned long sig, struct k_sigaction *ka,
533 siginfo_t *info, sigset_t *oldset, 533 siginfo_t *info, struct pt_regs *regs)
534 struct pt_regs * regs)
535{ 534{
536 struct thread_info *thread = current_thread_info(); 535 struct thread_info *thread = current_thread_info();
537 struct task_struct *tsk = current; 536 struct task_struct *tsk = current;
537 sigset_t *oldset = sigmask_to_save();
538 int usig = sig; 538 int usig = sig;
539 int ret; 539 int ret;
540 540
@@ -617,8 +617,6 @@ static void do_signal(struct pt_regs *regs, int syscall)
617 */ 617 */
618 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 618 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
619 if (signr > 0) { 619 if (signr > 0) {
620 sigset_t *oldset;
621
622 /* 620 /*
623 * Depending on the signal settings we may need to revert the 621 * Depending on the signal settings we may need to revert the
624 * decision to restart the system call. But skip this if a 622 * decision to restart the system call. But skip this if a
@@ -635,11 +633,7 @@ static void do_signal(struct pt_regs *regs, int syscall)
635 clear_thread_flag(TIF_SYSCALL_RESTARTSYS); 633 clear_thread_flag(TIF_SYSCALL_RESTARTSYS);
636 } 634 }
637 635
638 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 636 if (handle_signal(signr, &ka, &info, regs) == 0) {
639 oldset = &current->saved_sigmask;
640 else
641 oldset = &current->blocked;
642 if (handle_signal(signr, &ka, &info, oldset, regs) == 0) {
643 /* 637 /*
644 * A signal was successfully delivered; the saved 638 * A signal was successfully delivered; the saved
645 * sigmask will have been stored in the signal frame, 639 * sigmask will have been stored in the signal frame,
diff --git a/arch/avr32/kernel/signal.c b/arch/avr32/kernel/signal.c
index 8b12c3046137..0e2c0527c9fe 100644
--- a/arch/avr32/kernel/signal.c
+++ b/arch/avr32/kernel/signal.c
@@ -224,14 +224,14 @@ static inline void setup_syscall_restart(struct pt_regs *regs)
224 224
225static inline void 225static inline void
226handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, 226handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
227 sigset_t *oldset, struct pt_regs *regs, int syscall) 227 struct pt_regs *regs, int syscall)
228{ 228{
229 int ret; 229 int ret;
230 230
231 /* 231 /*
232 * Set up the stack frame 232 * Set up the stack frame
233 */ 233 */
234 ret = setup_rt_frame(sig, ka, info, oldset, regs); 234 ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);
235 235
236 /* 236 /*
237 * Check that the resulting registers are sane 237 * Check that the resulting registers are sane
@@ -255,7 +255,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
255 * doesn't want to handle. Thus you cannot kill init even with a 255 * doesn't want to handle. Thus you cannot kill init even with a
256 * SIGKILL even by mistake. 256 * SIGKILL even by mistake.
257 */ 257 */
258int do_signal(struct pt_regs *regs, sigset_t *oldset, int syscall) 258static void do_signal(struct pt_regs *regs, int syscall)
259{ 259{
260 siginfo_t info; 260 siginfo_t info;
261 int signr; 261 int signr;
@@ -267,12 +267,7 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset, int syscall)
267 * without doing anything if so. 267 * without doing anything if so.
268 */ 268 */
269 if (!user_mode(regs)) 269 if (!user_mode(regs))
270 return 0; 270 return;
271
272 if (test_thread_flag(TIF_RESTORE_SIGMASK))
273 oldset = &current->saved_sigmask;
274 else if (!oldset)
275 oldset = &current->blocked;
276 271
277 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 272 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
278 if (syscall) { 273 if (syscall) {
@@ -298,11 +293,10 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset, int syscall)
298 if (signr == 0) { 293 if (signr == 0) {
299 /* No signal to deliver -- put the saved sigmask back */ 294 /* No signal to deliver -- put the saved sigmask back */
300 restore_saved_sigmask(); 295 restore_saved_sigmask();
301 return 0; 296 return;
302 } 297 }
303 298
304 handle_signal(signr, &ka, &info, oldset, regs, syscall); 299 handle_signal(signr, &ka, &info, regs, syscall);
305 return 1;
306} 300}
307 301
308asmlinkage void do_notify_resume(struct pt_regs *regs, struct thread_info *ti) 302asmlinkage void do_notify_resume(struct pt_regs *regs, struct thread_info *ti)
@@ -313,7 +307,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, struct thread_info *ti)
313 syscall = 1; 307 syscall = 1;
314 308
315 if (ti->flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)) 309 if (ti->flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK))
316 do_signal(regs, &current->blocked, syscall); 310 do_signal(regs, syscall);
317 311
318 if (ti->flags & _TIF_NOTIFY_RESUME) { 312 if (ti->flags & _TIF_NOTIFY_RESUME) {
319 clear_thread_flag(TIF_NOTIFY_RESUME); 313 clear_thread_flag(TIF_NOTIFY_RESUME);
diff --git a/arch/blackfin/kernel/signal.c b/arch/blackfin/kernel/signal.c
index 9d692a1277b3..7f4205ddfa4d 100644
--- a/arch/blackfin/kernel/signal.c
+++ b/arch/blackfin/kernel/signal.c
@@ -249,7 +249,7 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
249 */ 249 */
250static int 250static int
251handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka, 251handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
252 sigset_t *oldset, struct pt_regs *regs) 252 struct pt_regs *regs)
253{ 253{
254 int ret; 254 int ret;
255 255
@@ -259,7 +259,7 @@ handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
259 handle_restart(regs, ka, 1); 259 handle_restart(regs, ka, 1);
260 260
261 /* set up the stack frame */ 261 /* set up the stack frame */
262 ret = setup_rt_frame(sig, ka, info, oldset, regs); 262 ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);
263 263
264 if (ret == 0) 264 if (ret == 0)
265 block_sigmask(ka, sig); 265 block_sigmask(ka, sig);
@@ -281,22 +281,16 @@ asmlinkage void do_signal(struct pt_regs *regs)
281 siginfo_t info; 281 siginfo_t info;
282 int signr; 282 int signr;
283 struct k_sigaction ka; 283 struct k_sigaction ka;
284 sigset_t *oldset;
285 284
286 current->thread.esp0 = (unsigned long)regs; 285 current->thread.esp0 = (unsigned long)regs;
287 286
288 if (try_to_freeze()) 287 if (try_to_freeze())
289 goto no_signal; 288 goto no_signal;
290 289
291 if (test_thread_flag(TIF_RESTORE_SIGMASK))
292 oldset = &current->saved_sigmask;
293 else
294 oldset = &current->blocked;
295
296 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 290 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
297 if (signr > 0) { 291 if (signr > 0) {
298 /* Whee! Actually deliver the signal. */ 292 /* Whee! Actually deliver the signal. */
299 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { 293 if (handle_signal(signr, &info, &ka, regs) == 0) {
300 /* a signal was successfully delivered; the saved 294 /* a signal was successfully delivered; the saved
301 * sigmask will have been stored in the signal frame, 295 * sigmask will have been stored in the signal frame,
302 * and will be restored by sigreturn, so we can simply 296 * and will be restored by sigreturn, so we can simply
diff --git a/arch/c6x/kernel/signal.c b/arch/c6x/kernel/signal.c
index bfbcc958bbb4..38bb501eb117 100644
--- a/arch/c6x/kernel/signal.c
+++ b/arch/c6x/kernel/signal.c
@@ -250,8 +250,7 @@ do_restart:
250 */ 250 */
251static int handle_signal(int sig, 251static int handle_signal(int sig,
252 siginfo_t *info, struct k_sigaction *ka, 252 siginfo_t *info, struct k_sigaction *ka,
253 sigset_t *oldset, struct pt_regs *regs, 253 struct pt_regs *regs, int syscall)
254 int syscall)
255{ 254{
256 int ret; 255 int ret;
257 256
@@ -278,7 +277,7 @@ static int handle_signal(int sig,
278 } 277 }
279 278
280 /* Set up the stack frame */ 279 /* Set up the stack frame */
281 ret = setup_rt_frame(sig, ka, info, oldset, regs); 280 ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);
282 if (ret == 0) 281 if (ret == 0)
283 block_sigmask(ka, sig); 282 block_sigmask(ka, sig);
284 283
@@ -292,7 +291,6 @@ static void do_signal(struct pt_regs *regs, int syscall)
292{ 291{
293 struct k_sigaction ka; 292 struct k_sigaction ka;
294 siginfo_t info; 293 siginfo_t info;
295 sigset_t *oldset;
296 int signr; 294 int signr;
297 295
298 /* we want the common case to go fast, which is why we may in certain 296 /* we want the common case to go fast, which is why we may in certain
@@ -300,15 +298,9 @@ static void do_signal(struct pt_regs *regs, int syscall)
300 if (!user_mode(regs)) 298 if (!user_mode(regs))
301 return; 299 return;
302 300
303 if (test_thread_flag(TIF_RESTORE_SIGMASK))
304 oldset = &current->saved_sigmask;
305 else
306 oldset = &current->blocked;
307
308 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 301 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
309 if (signr > 0) { 302 if (signr > 0) {
310 if (handle_signal(signr, &info, &ka, oldset, 303 if (handle_signal(signr, &info, &ka, regs, syscall) == 0) {
311 regs, syscall) == 0) {
312 /* a signal was successfully delivered; the saved 304 /* a signal was successfully delivered; the saved
313 * sigmask will have been stored in the signal frame, 305 * sigmask will have been stored in the signal frame,
314 * and will be restored by sigreturn, so we can simply 306 * and will be restored by sigreturn, so we can simply
diff --git a/arch/cris/arch-v10/kernel/signal.c b/arch/cris/arch-v10/kernel/signal.c
index 06885e94e455..09a4cf4eb08a 100644
--- a/arch/cris/arch-v10/kernel/signal.c
+++ b/arch/cris/arch-v10/kernel/signal.c
@@ -417,8 +417,9 @@ give_sigsegv:
417 417
418static inline int handle_signal(int canrestart, unsigned long sig, 418static inline int handle_signal(int canrestart, unsigned long sig,
419 siginfo_t *info, struct k_sigaction *ka, 419 siginfo_t *info, struct k_sigaction *ka,
420 sigset_t *oldset, struct pt_regs *regs) 420 struct pt_regs *regs)
421{ 421{
422 sigset_t *oldset = sigmask_to_save();
422 int ret; 423 int ret;
423 424
424 /* Are we from a system call? */ 425 /* Are we from a system call? */
@@ -478,7 +479,6 @@ void do_signal(int canrestart, struct pt_regs *regs)
478 siginfo_t info; 479 siginfo_t info;
479 int signr; 480 int signr;
480 struct k_sigaction ka; 481 struct k_sigaction ka;
481 sigset_t *oldset;
482 482
483 /* 483 /*
484 * We want the common case to go fast, which 484 * We want the common case to go fast, which
@@ -489,16 +489,11 @@ void do_signal(int canrestart, struct pt_regs *regs)
489 if (!user_mode(regs)) 489 if (!user_mode(regs))
490 return; 490 return;
491 491
492 if (test_thread_flag(TIF_RESTORE_SIGMASK))
493 oldset = &current->saved_sigmask;
494 else
495 oldset = &current->blocked;
496
497 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 492 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
498 if (signr > 0) { 493 if (signr > 0) {
499 /* Whee! Actually deliver the signal. */ 494 /* Whee! Actually deliver the signal. */
500 if (handle_signal(canrestart, signr, &info, &ka, 495 if (handle_signal(canrestart, signr, &info, &ka,
501 oldset, regs)) { 496 regs)) {
502 /* a signal was successfully delivered; the saved 497 /* a signal was successfully delivered; the saved
503 * sigmask will have been stored in the signal frame, 498 * sigmask will have been stored in the signal frame,
504 * and will be restored by sigreturn, so we can simply 499 * and will be restored by sigreturn, so we can simply
diff --git a/arch/cris/arch-v32/kernel/signal.c b/arch/cris/arch-v32/kernel/signal.c
index fe12cdca0bac..d52276ddae4b 100644
--- a/arch/cris/arch-v32/kernel/signal.c
+++ b/arch/cris/arch-v32/kernel/signal.c
@@ -437,8 +437,9 @@ give_sigsegv:
437static inline int 437static inline int
438handle_signal(int canrestart, unsigned long sig, 438handle_signal(int canrestart, unsigned long sig,
439 siginfo_t *info, struct k_sigaction *ka, 439 siginfo_t *info, struct k_sigaction *ka,
440 sigset_t *oldset, struct pt_regs * regs) 440 struct pt_regs * regs)
441{ 441{
442 sigset_t *oldset = sigmask_to_save();
442 int ret; 443 int ret;
443 444
444 /* Check if this got called from a system call. */ 445 /* Check if this got called from a system call. */
@@ -511,7 +512,6 @@ do_signal(int canrestart, struct pt_regs *regs)
511 int signr; 512 int signr;
512 siginfo_t info; 513 siginfo_t info;
513 struct k_sigaction ka; 514 struct k_sigaction ka;
514 sigset_t *oldset;
515 515
516 /* 516 /*
517 * The common case should go fast, which is why this point is 517 * The common case should go fast, which is why this point is
@@ -521,17 +521,12 @@ do_signal(int canrestart, struct pt_regs *regs)
521 if (!user_mode(regs)) 521 if (!user_mode(regs))
522 return; 522 return;
523 523
524 if (test_thread_flag(TIF_RESTORE_SIGMASK))
525 oldset = &current->saved_sigmask;
526 else
527 oldset = &current->blocked;
528
529 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 524 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
530 525
531 if (signr > 0) { 526 if (signr > 0) {
532 /* Whee! Actually deliver the signal. */ 527 /* Whee! Actually deliver the signal. */
533 if (handle_signal(canrestart, signr, &info, &ka, 528 if (handle_signal(canrestart, signr, &info, &ka,
534 oldset, regs)) { 529 regs)) {
535 /* a signal was successfully delivered; the saved 530 /* a signal was successfully delivered; the saved
536 * sigmask will have been stored in the signal frame, 531 * sigmask will have been stored in the signal frame,
537 * and will be restored by sigreturn, so we can simply 532 * and will be restored by sigreturn, so we can simply
diff --git a/arch/frv/kernel/signal.c b/arch/frv/kernel/signal.c
index 16351cc8c36c..22efe8d25038 100644
--- a/arch/frv/kernel/signal.c
+++ b/arch/frv/kernel/signal.c
@@ -427,8 +427,9 @@ give_sigsegv:
427 * OK, we're invoking a handler 427 * OK, we're invoking a handler
428 */ 428 */
429static int handle_signal(unsigned long sig, siginfo_t *info, 429static int handle_signal(unsigned long sig, siginfo_t *info,
430 struct k_sigaction *ka, sigset_t *oldset) 430 struct k_sigaction *ka)
431{ 431{
432 sigset_t *oldset = sigmask_to_save();
432 int ret; 433 int ret;
433 434
434 /* Are we from a system call? */ 435 /* Are we from a system call? */
@@ -492,14 +493,9 @@ static void do_signal(void)
492 if (try_to_freeze()) 493 if (try_to_freeze())
493 goto no_signal; 494 goto no_signal;
494 495
495 if (test_thread_flag(TIF_RESTORE_SIGMASK))
496 oldset = &current->saved_sigmask;
497 else
498 oldset = &current->blocked;
499
500 signr = get_signal_to_deliver(&info, &ka, __frame, NULL); 496 signr = get_signal_to_deliver(&info, &ka, __frame, NULL);
501 if (signr > 0) { 497 if (signr > 0) {
502 if (handle_signal(signr, &info, &ka, oldset) == 0) { 498 if (handle_signal(signr, &info, &ka) == 0) {
503 /* a signal was successfully delivered; the saved 499 /* a signal was successfully delivered; the saved
504 * sigmask will have been stored in the signal frame, 500 * sigmask will have been stored in the signal frame,
505 * and will be restored by sigreturn, so we can simply 501 * and will be restored by sigreturn, so we can simply
diff --git a/arch/h8300/kernel/signal.c b/arch/h8300/kernel/signal.c
index 63623dabab32..d4d2f72672ad 100644
--- a/arch/h8300/kernel/signal.c
+++ b/arch/h8300/kernel/signal.c
@@ -412,8 +412,9 @@ give_sigsegv:
412 */ 412 */
413static void 413static void
414handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, 414handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
415 sigset_t *oldset, struct pt_regs * regs) 415 struct pt_regs * regs)
416{ 416{
417 sigset_t *oldset = sigmask_to_save();
417 int ret; 418 int ret;
418 /* are we from a system call? */ 419 /* are we from a system call? */
419 if (regs->orig_er0 >= 0) { 420 if (regs->orig_er0 >= 0) {
@@ -457,7 +458,6 @@ statis void do_signal(struct pt_regs *regs)
457 siginfo_t info; 458 siginfo_t info;
458 int signr; 459 int signr;
459 struct k_sigaction ka; 460 struct k_sigaction ka;
460 sigset_t *oldset;
461 461
462 /* 462 /*
463 * We want the common case to go fast, which 463 * We want the common case to go fast, which
@@ -473,15 +473,10 @@ statis void do_signal(struct pt_regs *regs)
473 473
474 current->thread.esp0 = (unsigned long) regs; 474 current->thread.esp0 = (unsigned long) regs;
475 475
476 if (test_thread_flag(TIF_RESTORE_SIGMASK))
477 oldset = &current->saved_sigmask;
478 else
479 oldset = &current->blocked;
480
481 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 476 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
482 if (signr > 0) { 477 if (signr > 0) {
483 /* Whee! Actually deliver the signal. */ 478 /* Whee! Actually deliver the signal. */
484 handle_signal(signr, &info, &ka, oldset, regs); 479 handle_signal(signr, &info, &ka, regs);
485 return; 480 return;
486 } 481 }
487 no_signal: 482 no_signal:
diff --git a/arch/hexagon/kernel/signal.c b/arch/hexagon/kernel/signal.c
index acd6272913b3..f73fcee09bac 100644
--- a/arch/hexagon/kernel/signal.c
+++ b/arch/hexagon/kernel/signal.c
@@ -150,7 +150,7 @@ sigsegv:
150 * Setup invocation of signal handler 150 * Setup invocation of signal handler
151 */ 151 */
152static int handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka, 152static int handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
153 sigset_t *oldset, struct pt_regs *regs) 153 struct pt_regs *regs)
154{ 154{
155 int rc; 155 int rc;
156 156
@@ -186,7 +186,7 @@ static int handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
186 * Set up the stack frame; not doing the SA_SIGINFO thing. We 186 * Set up the stack frame; not doing the SA_SIGINFO thing. We
187 * only set up the rt_frame flavor. 187 * only set up the rt_frame flavor.
188 */ 188 */
189 rc = setup_rt_frame(sig, ka, info, oldset, regs); 189 rc = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);
190 190
191 /* If there was an error on setup, no signal was delivered. */ 191 /* If there was an error on setup, no signal was delivered. */
192 if (rc) 192 if (rc)
@@ -215,14 +215,7 @@ static void do_signal(struct pt_regs *regs)
215 signo = get_signal_to_deliver(&info, &sigact, regs, NULL); 215 signo = get_signal_to_deliver(&info, &sigact, regs, NULL);
216 216
217 if (signo > 0) { 217 if (signo > 0) {
218 sigset_t *oldset; 218 if (handle_signal(signo, &info, &sigact, regs) == 0) {
219
220 if (test_thread_flag(TIF_RESTORE_SIGMASK))
221 oldset = &current->saved_sigmask;
222 else
223 oldset = &current->blocked;
224
225 if (handle_signal(signo, &info, &sigact, oldset, regs) == 0) {
226 /* 219 /*
227 * Successful delivery case. The saved sigmask is 220 * Successful delivery case. The saved sigmask is
228 * stored in the signal frame, and will be restored 221 * stored in the signal frame, and will be restored
diff --git a/arch/ia64/kernel/signal.c b/arch/ia64/kernel/signal.c
index 39d8f3afff49..9fee6d6a3f21 100644
--- a/arch/ia64/kernel/signal.c
+++ b/arch/ia64/kernel/signal.c
@@ -415,10 +415,10 @@ setup_frame (int sig, struct k_sigaction *ka, siginfo_t *info, sigset_t *set,
415} 415}
416 416
417static long 417static long
418handle_signal (unsigned long sig, struct k_sigaction *ka, siginfo_t *info, sigset_t *oldset, 418handle_signal (unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
419 struct sigscratch *scr) 419 struct sigscratch *scr)
420{ 420{
421 if (!setup_frame(sig, ka, info, oldset, scr)) 421 if (!setup_frame(sig, ka, info, sigmask_to_save(), scr))
422 return 0; 422 return 0;
423 423
424 block_sigmask(ka, sig); 424 block_sigmask(ka, sig);
@@ -440,7 +440,6 @@ void
440ia64_do_signal (struct sigscratch *scr, long in_syscall) 440ia64_do_signal (struct sigscratch *scr, long in_syscall)
441{ 441{
442 struct k_sigaction ka; 442 struct k_sigaction ka;
443 sigset_t *oldset;
444 siginfo_t info; 443 siginfo_t info;
445 long restart = in_syscall; 444 long restart = in_syscall;
446 long errno = scr->pt.r8; 445 long errno = scr->pt.r8;
@@ -453,11 +452,6 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall)
453 if (!user_mode(&scr->pt)) 452 if (!user_mode(&scr->pt))
454 return; 453 return;
455 454
456 if (current_thread_info()->status & TS_RESTORE_SIGMASK)
457 oldset = &current->saved_sigmask;
458 else
459 oldset = &current->blocked;
460
461 /* 455 /*
462 * This only loops in the rare cases of handle_signal() failing, in which case we 456 * This only loops in the rare cases of handle_signal() failing, in which case we
463 * need to push through a forced SIGSEGV. 457 * need to push through a forced SIGSEGV.
@@ -507,7 +501,7 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall)
507 * Whee! Actually deliver the signal. If the delivery failed, we need to 501 * Whee! Actually deliver the signal. If the delivery failed, we need to
508 * continue to iterate in this loop so we can deliver the SIGSEGV... 502 * continue to iterate in this loop so we can deliver the SIGSEGV...
509 */ 503 */
510 if (handle_signal(signr, &ka, &info, oldset, scr)) { 504 if (handle_signal(signr, &ka, &info, scr)) {
511 /* 505 /*
512 * A signal was successfully delivered; the saved 506 * A signal was successfully delivered; the saved
513 * sigmask will have been stored in the signal frame, 507 * sigmask will have been stored in the signal frame,
diff --git a/arch/m32r/kernel/signal.c b/arch/m32r/kernel/signal.c
index 2ad7c4587669..e0d6d1079f33 100644
--- a/arch/m32r/kernel/signal.c
+++ b/arch/m32r/kernel/signal.c
@@ -269,7 +269,7 @@ static int prev_insn(struct pt_regs *regs)
269 269
270static int 270static int
271handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, 271handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
272 sigset_t *oldset, struct pt_regs *regs) 272 struct pt_regs *regs)
273{ 273{
274 /* Are we from a system call? */ 274 /* Are we from a system call? */
275 if (regs->syscall_nr >= 0) { 275 if (regs->syscall_nr >= 0) {
@@ -294,7 +294,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
294 } 294 }
295 295
296 /* Set up the stack frame */ 296 /* Set up the stack frame */
297 if (setup_rt_frame(sig, ka, info, oldset, regs)) 297 if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs))
298 return -EFAULT; 298 return -EFAULT;
299 299
300 block_sigmask(ka, sig); 300 block_sigmask(ka, sig);
@@ -311,7 +311,6 @@ static void do_signal(struct pt_regs *regs)
311 siginfo_t info; 311 siginfo_t info;
312 int signr; 312 int signr;
313 struct k_sigaction ka; 313 struct k_sigaction ka;
314 sigset_t *oldset;
315 314
316 /* 315 /*
317 * We want the common case to go fast, which 316 * We want the common case to go fast, which
@@ -325,11 +324,6 @@ static void do_signal(struct pt_regs *regs)
325 if (try_to_freeze()) 324 if (try_to_freeze())
326 goto no_signal; 325 goto no_signal;
327 326
328 if (test_thread_flag(TIF_RESTORE_SIGMASK))
329 oldset = &current->saved_sigmask;
330 else
331 oldset = &current->blocked;
332
333 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 327 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
334 if (signr > 0) { 328 if (signr > 0) {
335 /* Re-enable any watchpoints before delivering the 329 /* Re-enable any watchpoints before delivering the
@@ -339,7 +333,7 @@ static void do_signal(struct pt_regs *regs)
339 */ 333 */
340 334
341 /* Whee! Actually deliver the signal. */ 335 /* Whee! Actually deliver the signal. */
342 if (handle_signal(signr, &ka, &info, oldset, regs) == 0) 336 if (handle_signal(signr, &ka, &info, regs) == 0)
343 clear_thread_flag(TIF_RESTORE_SIGMASK); 337 clear_thread_flag(TIF_RESTORE_SIGMASK);
344 338
345 return; 339 return;
diff --git a/arch/m68k/kernel/signal.c b/arch/m68k/kernel/signal.c
index 685cbe84f33f..c83eb5a8ed8b 100644
--- a/arch/m68k/kernel/signal.c
+++ b/arch/m68k/kernel/signal.c
@@ -1123,8 +1123,9 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
1123 */ 1123 */
1124static void 1124static void
1125handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info, 1125handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
1126 sigset_t *oldset, struct pt_regs *regs) 1126 struct pt_regs *regs)
1127{ 1127{
1128 sigset_t *oldset = sigmask_to_save();
1128 int err; 1129 int err;
1129 /* are we from a system call? */ 1130 /* are we from a system call? */
1130 if (regs->orig_d0 >= 0) 1131 if (regs->orig_d0 >= 0)
@@ -1160,19 +1161,13 @@ static void do_signal(struct pt_regs *regs)
1160 siginfo_t info; 1161 siginfo_t info;
1161 struct k_sigaction ka; 1162 struct k_sigaction ka;
1162 int signr; 1163 int signr;
1163 sigset_t *oldset;
1164 1164
1165 current->thread.esp0 = (unsigned long) regs; 1165 current->thread.esp0 = (unsigned long) regs;
1166 1166
1167 if (test_thread_flag(TIF_RESTORE_SIGMASK))
1168 oldset = &current->saved_sigmask;
1169 else
1170 oldset = &current->blocked;
1171
1172 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 1167 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
1173 if (signr > 0) { 1168 if (signr > 0) {
1174 /* Whee! Actually deliver the signal. */ 1169 /* Whee! Actually deliver the signal. */
1175 handle_signal(signr, &ka, &info, oldset, regs); 1170 handle_signal(signr, &ka, &info, regs);
1176 return; 1171 return;
1177 } 1172 }
1178 1173
diff --git a/arch/microblaze/kernel/signal.c b/arch/microblaze/kernel/signal.c
index 8e644dfaba4f..fd2de5718a4e 100644
--- a/arch/microblaze/kernel/signal.c
+++ b/arch/microblaze/kernel/signal.c
@@ -312,8 +312,9 @@ do_restart:
312 312
313static int 313static int
314handle_signal(unsigned long sig, struct k_sigaction *ka, 314handle_signal(unsigned long sig, struct k_sigaction *ka,
315 siginfo_t *info, sigset_t *oldset, struct pt_regs *regs) 315 siginfo_t *info, struct pt_regs *regs)
316{ 316{
317 sigset_t *oldset = sigmask_to_save();
317 int ret; 318 int ret;
318 319
319 /* Set up the stack frame */ 320 /* Set up the stack frame */
@@ -344,18 +345,12 @@ static void do_signal(struct pt_regs *regs, int in_syscall)
344 siginfo_t info; 345 siginfo_t info;
345 int signr; 346 int signr;
346 struct k_sigaction ka; 347 struct k_sigaction ka;
347 sigset_t *oldset;
348#ifdef DEBUG_SIG 348#ifdef DEBUG_SIG
349 printk(KERN_INFO "do signal: %p %d\n", regs, in_syscall); 349 printk(KERN_INFO "do signal: %p %d\n", regs, in_syscall);
350 printk(KERN_INFO "do signal2: %lx %lx %ld [%lx]\n", regs->pc, regs->r1, 350 printk(KERN_INFO "do signal2: %lx %lx %ld [%lx]\n", regs->pc, regs->r1,
351 regs->r12, current_thread_info()->flags); 351 regs->r12, current_thread_info()->flags);
352#endif 352#endif
353 353
354 if (current_thread_info()->status & TS_RESTORE_SIGMASK)
355 oldset = &current->saved_sigmask;
356 else
357 oldset = &current->blocked;
358
359 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 354 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
360 if (signr > 0) { 355 if (signr > 0) {
361 /* Whee! Actually deliver the signal. */ 356 /* Whee! Actually deliver the signal. */
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
index aad2d2da5eec..18355060f241 100644
--- a/arch/mips/kernel/signal.c
+++ b/arch/mips/kernel/signal.c
@@ -515,8 +515,9 @@ struct mips_abi mips_abi = {
515}; 515};
516 516
517static int handle_signal(unsigned long sig, siginfo_t *info, 517static int handle_signal(unsigned long sig, siginfo_t *info,
518 struct k_sigaction *ka, sigset_t *oldset, struct pt_regs *regs) 518 struct k_sigaction *ka, struct pt_regs *regs)
519{ 519{
520 sigset_t *oldset = sigmask_to_save();
520 int ret; 521 int ret;
521 struct mips_abi *abi = current->thread.abi; 522 struct mips_abi *abi = current->thread.abi;
522 void *vdso = current->mm->context.vdso; 523 void *vdso = current->mm->context.vdso;
@@ -560,7 +561,6 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
560static void do_signal(struct pt_regs *regs) 561static void do_signal(struct pt_regs *regs)
561{ 562{
562 struct k_sigaction ka; 563 struct k_sigaction ka;
563 sigset_t *oldset;
564 siginfo_t info; 564 siginfo_t info;
565 int signr; 565 int signr;
566 566
@@ -572,15 +572,10 @@ static void do_signal(struct pt_regs *regs)
572 if (!user_mode(regs)) 572 if (!user_mode(regs))
573 return; 573 return;
574 574
575 if (test_thread_flag(TIF_RESTORE_SIGMASK))
576 oldset = &current->saved_sigmask;
577 else
578 oldset = &current->blocked;
579
580 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 575 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
581 if (signr > 0) { 576 if (signr > 0) {
582 /* Whee! Actually deliver the signal. */ 577 /* Whee! Actually deliver the signal. */
583 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { 578 if (handle_signal(signr, &info, &ka, regs) == 0) {
584 /* 579 /*
585 * A signal was successfully delivered; the saved 580 * A signal was successfully delivered; the saved
586 * sigmask will have been stored in the signal frame, 581 * sigmask will have been stored in the signal frame,
diff --git a/arch/mn10300/kernel/signal.c b/arch/mn10300/kernel/signal.c
index b7994c38eacc..26a1d98c62a1 100644
--- a/arch/mn10300/kernel/signal.c
+++ b/arch/mn10300/kernel/signal.c
@@ -430,8 +430,9 @@ static inline void stepback(struct pt_regs *regs)
430 */ 430 */
431static int handle_signal(int sig, 431static int handle_signal(int sig,
432 siginfo_t *info, struct k_sigaction *ka, 432 siginfo_t *info, struct k_sigaction *ka,
433 sigset_t *oldset, struct pt_regs *regs) 433 struct pt_regs *regs)
434{ 434{
435 sigset_t *oldset = sigmask_to_save();
435 int ret; 436 int ret;
436 437
437 /* Are we from a system call? */ 438 /* Are we from a system call? */
@@ -475,7 +476,6 @@ static void do_signal(struct pt_regs *regs)
475{ 476{
476 struct k_sigaction ka; 477 struct k_sigaction ka;
477 siginfo_t info; 478 siginfo_t info;
478 sigset_t *oldset;
479 int signr; 479 int signr;
480 480
481 /* we want the common case to go fast, which is why we may in certain 481 /* we want the common case to go fast, which is why we may in certain
@@ -483,14 +483,9 @@ static void do_signal(struct pt_regs *regs)
483 if (!user_mode(regs)) 483 if (!user_mode(regs))
484 return; 484 return;
485 485
486 if (test_thread_flag(TIF_RESTORE_SIGMASK))
487 oldset = &current->saved_sigmask;
488 else
489 oldset = &current->blocked;
490
491 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 486 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
492 if (signr > 0) { 487 if (signr > 0) {
493 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { 488 if (handle_signal(signr, &info, &ka, regs) == 0) {
494 /* a signal was successfully delivered; the saved 489 /* a signal was successfully delivered; the saved
495 * sigmask will have been stored in the signal frame, 490 * sigmask will have been stored in the signal frame,
496 * and will be restored by sigreturn, so we can simply 491 * and will be restored by sigreturn, so we can simply
diff --git a/arch/openrisc/kernel/signal.c b/arch/openrisc/kernel/signal.c
index 266c6fd2eb5c..721c584ff44a 100644
--- a/arch/openrisc/kernel/signal.c
+++ b/arch/openrisc/kernel/signal.c
@@ -254,11 +254,11 @@ give_sigsegv:
254static inline int 254static inline int
255handle_signal(unsigned long sig, 255handle_signal(unsigned long sig,
256 siginfo_t *info, struct k_sigaction *ka, 256 siginfo_t *info, struct k_sigaction *ka,
257 sigset_t *oldset, struct pt_regs *regs) 257 struct pt_regs *regs)
258{ 258{
259 int ret; 259 int ret;
260 260
261 ret = setup_rt_frame(sig, ka, info, oldset, regs); 261 ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);
262 if (ret) 262 if (ret)
263 return ret; 263 return ret;
264 264
@@ -341,15 +341,9 @@ void do_signal(struct pt_regs *regs)
341 * back */ 341 * back */
342 restore_saved_sigmask(); 342 restore_saved_sigmask();
343 } else { /* signr > 0 */ 343 } else { /* signr > 0 */
344 sigset_t *oldset;
345
346 if (current_thread_info()->flags & _TIF_RESTORE_SIGMASK)
347 oldset = &current->saved_sigmask;
348 else
349 oldset = &current->blocked;
350 344
351 /* Whee! Actually deliver the signal. */ 345 /* Whee! Actually deliver the signal. */
352 if (!handle_signal(signr, &info, &ka, oldset, regs)) { 346 if (!handle_signal(signr, &info, &ka, regs)) {
353 /* a signal was successfully delivered; the saved 347 /* a signal was successfully delivered; the saved
354 * sigmask will have been stored in the signal frame, 348 * sigmask will have been stored in the signal frame,
355 * and will be restored by sigreturn, so we can simply 349 * and will be restored by sigreturn, so we can simply
diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c
index 277cacadf653..441b25992846 100644
--- a/arch/parisc/kernel/signal.c
+++ b/arch/parisc/kernel/signal.c
@@ -443,8 +443,9 @@ give_sigsegv:
443 443
444static long 444static long
445handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, 445handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
446 sigset_t *oldset, struct pt_regs *regs, int in_syscall) 446 struct pt_regs *regs, int in_syscall)
447{ 447{
448 sigset_t *oldset = sigmask_to_save();
448 DBG(1,"handle_signal: sig=%ld, ka=%p, info=%p, oldset=%p, regs=%p\n", 449 DBG(1,"handle_signal: sig=%ld, ka=%p, info=%p, oldset=%p, regs=%p\n",
449 sig, ka, info, oldset, regs); 450 sig, ka, info, oldset, regs);
450 451
@@ -568,28 +569,17 @@ do_signal(struct pt_regs *regs, long in_syscall)
568 siginfo_t info; 569 siginfo_t info;
569 struct k_sigaction ka; 570 struct k_sigaction ka;
570 int signr; 571 int signr;
571 sigset_t *oldset;
572 572
573 DBG(1,"\ndo_signal: oldset=0x%p, regs=0x%p, sr7 %#lx, in_syscall=%d\n", 573 DBG(1,"\ndo_signal: regs=0x%p, sr7 %#lx, in_syscall=%d\n",
574 oldset, regs, regs->sr[7], in_syscall); 574 regs, regs->sr[7], in_syscall);
575 575
576 /* Everyone else checks to see if they are in kernel mode at 576 /* Everyone else checks to see if they are in kernel mode at
577 this point and exits if that's the case. I'm not sure why 577 this point and exits if that's the case. I'm not sure why
578 we would be called in that case, but for some reason we 578 we would be called in that case, but for some reason we
579 are. */ 579 are. */
580 580
581 if (test_thread_flag(TIF_RESTORE_SIGMASK))
582 oldset = &current->saved_sigmask;
583 else
584 oldset = &current->blocked;
585
586 DBG(1,"do_signal: oldset %08lx / %08lx\n",
587 oldset->sig[0], oldset->sig[1]);
588
589
590 /* May need to force signal if handle_signal failed to deliver */ 581 /* May need to force signal if handle_signal failed to deliver */
591 while (1) { 582 while (1) {
592
593 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 583 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
594 DBG(3,"do_signal: signr = %d, regs->gr[28] = %ld\n", signr, regs->gr[28]); 584 DBG(3,"do_signal: signr = %d, regs->gr[28] = %ld\n", signr, regs->gr[28]);
595 585
@@ -603,8 +593,7 @@ do_signal(struct pt_regs *regs, long in_syscall)
603 /* Whee! Actually deliver the signal. If the 593 /* Whee! Actually deliver the signal. If the
604 delivery failed, we need to continue to iterate in 594 delivery failed, we need to continue to iterate in
605 this loop so we can deliver the SIGSEGV... */ 595 this loop so we can deliver the SIGSEGV... */
606 if (handle_signal(signr, &info, &ka, oldset, 596 if (handle_signal(signr, &info, &ka, regs, in_syscall)) {
607 regs, in_syscall)) {
608 DBG(1,KERN_DEBUG "do_signal: Exit (success), regs->gr[28] = %ld\n", 597 DBG(1,KERN_DEBUG "do_signal: Exit (success), regs->gr[28] = %ld\n",
609 regs->gr[28]); 598 regs->gr[28]);
610 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 599 if (test_thread_flag(TIF_RESTORE_SIGMASK))
diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
index 0f4cc67f4268..8e9ddab7ade6 100644
--- a/arch/powerpc/kernel/signal.c
+++ b/arch/powerpc/kernel/signal.c
@@ -114,18 +114,13 @@ static void check_syscall_restart(struct pt_regs *regs, struct k_sigaction *ka,
114 114
115static int do_signal(struct pt_regs *regs) 115static int do_signal(struct pt_regs *regs)
116{ 116{
117 sigset_t *oldset; 117 sigset_t *oldset = sigmask_to_save();
118 siginfo_t info; 118 siginfo_t info;
119 int signr; 119 int signr;
120 struct k_sigaction ka; 120 struct k_sigaction ka;
121 int ret; 121 int ret;
122 int is32 = is_32bit_task(); 122 int is32 = is_32bit_task();
123 123
124 if (current_thread_info()->local_flags & _TLF_RESTORE_SIGMASK)
125 oldset = &current->saved_sigmask;
126 else
127 oldset = &current->blocked;
128
129 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 124 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
130 125
131 /* Is there any syscall restart business here ? */ 126 /* Is there any syscall restart business here ? */
diff --git a/arch/s390/kernel/signal.c b/arch/s390/kernel/signal.c
index 37799089c38e..c880c48a09f3 100644
--- a/arch/s390/kernel/signal.c
+++ b/arch/s390/kernel/signal.c
@@ -398,12 +398,7 @@ void do_signal(struct pt_regs *regs)
398 siginfo_t info; 398 siginfo_t info;
399 int signr; 399 int signr;
400 struct k_sigaction ka; 400 struct k_sigaction ka;
401 sigset_t *oldset; 401 sigset_t *oldset = sigmask_to_save();
402
403 if (test_thread_flag(TIF_RESTORE_SIGMASK))
404 oldset = &current->saved_sigmask;
405 else
406 oldset = &current->blocked;
407 402
408 /* 403 /*
409 * Get signal to deliver. When running under ptrace, at this point 404 * Get signal to deliver. When running under ptrace, at this point
diff --git a/arch/score/kernel/signal.c b/arch/score/kernel/signal.c
index 9e751559375b..b24dfaf2462f 100644
--- a/arch/score/kernel/signal.c
+++ b/arch/score/kernel/signal.c
@@ -242,7 +242,7 @@ give_sigsegv:
242} 242}
243 243
244static int handle_signal(unsigned long sig, siginfo_t *info, 244static int handle_signal(unsigned long sig, siginfo_t *info,
245 struct k_sigaction *ka, sigset_t *oldset, struct pt_regs *regs) 245 struct k_sigaction *ka, struct pt_regs *regs)
246{ 246{
247 int ret; 247 int ret;
248 248
@@ -269,7 +269,7 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
269 /* 269 /*
270 * Set up the stack frame 270 * Set up the stack frame
271 */ 271 */
272 ret = setup_rt_frame(ka, regs, sig, oldset, info); 272 ret = setup_rt_frame(ka, regs, sig, sigmask_to_save(), info);
273 273
274 if (ret == 0) 274 if (ret == 0)
275 block_sigmask(ka, sig); 275 block_sigmask(ka, sig);
@@ -280,7 +280,6 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
280static void do_signal(struct pt_regs *regs) 280static void do_signal(struct pt_regs *regs)
281{ 281{
282 struct k_sigaction ka; 282 struct k_sigaction ka;
283 sigset_t *oldset;
284 siginfo_t info; 283 siginfo_t info;
285 int signr; 284 int signr;
286 285
@@ -292,15 +291,10 @@ static void do_signal(struct pt_regs *regs)
292 if (!user_mode(regs)) 291 if (!user_mode(regs))
293 return; 292 return;
294 293
295 if (test_thread_flag(TIF_RESTORE_SIGMASK))
296 oldset = &current->saved_sigmask;
297 else
298 oldset = &current->blocked;
299
300 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 294 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
301 if (signr > 0) { 295 if (signr > 0) {
302 /* Actually deliver the signal. */ 296 /* Actually deliver the signal. */
303 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { 297 if (handle_signal(signr, &info, &ka, regs) == 0) {
304 /* 298 /*
305 * A signal was successfully delivered; the saved 299 * A signal was successfully delivered; the saved
306 * sigmask will have been stored in the signal frame, 300 * sigmask will have been stored in the signal frame,
diff --git a/arch/sh/kernel/signal_32.c b/arch/sh/kernel/signal_32.c
index 92f4173ad29a..bfb3d599f032 100644
--- a/arch/sh/kernel/signal_32.c
+++ b/arch/sh/kernel/signal_32.c
@@ -524,8 +524,9 @@ handle_syscall_restart(unsigned long save_r0, struct pt_regs *regs,
524 */ 524 */
525static int 525static int
526handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, 526handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
527 sigset_t *oldset, struct pt_regs *regs, unsigned int save_r0) 527 struct pt_regs *regs, unsigned int save_r0)
528{ 528{
529 sigset_t *oldset = sigmask_to_save();
529 int ret; 530 int ret;
530 531
531 /* Set up the stack frame */ 532 /* Set up the stack frame */
@@ -554,7 +555,6 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0)
554 siginfo_t info; 555 siginfo_t info;
555 int signr; 556 int signr;
556 struct k_sigaction ka; 557 struct k_sigaction ka;
557 sigset_t *oldset;
558 558
559 /* 559 /*
560 * We want the common case to go fast, which 560 * We want the common case to go fast, which
@@ -565,17 +565,12 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0)
565 if (!user_mode(regs)) 565 if (!user_mode(regs))
566 return; 566 return;
567 567
568 if (current_thread_info()->status & TS_RESTORE_SIGMASK)
569 oldset = &current->saved_sigmask;
570 else
571 oldset = &current->blocked;
572
573 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 568 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
574 if (signr > 0) { 569 if (signr > 0) {
575 handle_syscall_restart(save_r0, regs, &ka.sa); 570 handle_syscall_restart(save_r0, regs, &ka.sa);
576 571
577 /* Whee! Actually deliver the signal. */ 572 /* Whee! Actually deliver the signal. */
578 if (handle_signal(signr, &ka, &info, oldset, 573 if (handle_signal(signr, &ka, &info,
579 regs, save_r0) == 0) { 574 regs, save_r0) == 0) {
580 /* 575 /*
581 * A signal was successfully delivered; the saved 576 * A signal was successfully delivered; the saved
diff --git a/arch/sh/kernel/signal_64.c b/arch/sh/kernel/signal_64.c
index 6e191ef0aa62..cc22d2b2e3f2 100644
--- a/arch/sh/kernel/signal_64.c
+++ b/arch/sh/kernel/signal_64.c
@@ -45,7 +45,7 @@
45 45
46static int 46static int
47handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, 47handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
48 sigset_t *oldset, struct pt_regs * regs); 48 struct pt_regs * regs);
49 49
50static inline void 50static inline void
51handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa) 51handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa)
@@ -88,7 +88,6 @@ static void do_signal(struct pt_regs *regs)
88 siginfo_t info; 88 siginfo_t info;
89 int signr; 89 int signr;
90 struct k_sigaction ka; 90 struct k_sigaction ka;
91 sigset_t *oldset;
92 91
93 /* 92 /*
94 * We want the common case to go fast, which 93 * We want the common case to go fast, which
@@ -99,17 +98,12 @@ static void do_signal(struct pt_regs *regs)
99 if (!user_mode(regs)) 98 if (!user_mode(regs))
100 return; 99 return;
101 100
102 if (current_thread_info()->status & TS_RESTORE_SIGMASK)
103 oldset = &current->saved_sigmask;
104 else
105 oldset = &current->blocked;
106
107 signr = get_signal_to_deliver(&info, &ka, regs, 0); 101 signr = get_signal_to_deliver(&info, &ka, regs, 0);
108 if (signr > 0) { 102 if (signr > 0) {
109 handle_syscall_restart(regs, &ka.sa); 103 handle_syscall_restart(regs, &ka.sa);
110 104
111 /* Whee! Actually deliver the signal. */ 105 /* Whee! Actually deliver the signal. */
112 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { 106 if (handle_signal(signr, &info, &ka, regs) == 0) {
113 /* 107 /*
114 * If a signal was successfully delivered, the 108 * If a signal was successfully delivered, the
115 * saved sigmask is in its frame, and we can 109 * saved sigmask is in its frame, and we can
@@ -656,8 +650,9 @@ give_sigsegv:
656 */ 650 */
657static int 651static int
658handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, 652handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
659 sigset_t *oldset, struct pt_regs * regs) 653 struct pt_regs * regs)
660{ 654{
655 sigset_t *oldset = sigmask_to_save();
661 int ret; 656 int ret;
662 657
663 /* Set up the stack frame */ 658 /* Set up the stack frame */
diff --git a/arch/sparc/kernel/signal_32.c b/arch/sparc/kernel/signal_32.c
index 9dd97d2e171e..5d74410c787b 100644
--- a/arch/sparc/kernel/signal_32.c
+++ b/arch/sparc/kernel/signal_32.c
@@ -451,8 +451,9 @@ sigsegv:
451 451
452static inline int 452static inline int
453handle_signal(unsigned long signr, struct k_sigaction *ka, 453handle_signal(unsigned long signr, struct k_sigaction *ka,
454 siginfo_t *info, sigset_t *oldset, struct pt_regs *regs) 454 siginfo_t *info, struct pt_regs *regs)
455{ 455{
456 sigset_t *oldset = sigmask_to_save();
456 int err; 457 int err;
457 458
458 if (ka->sa.sa_flags & SA_SIGINFO) 459 if (ka->sa.sa_flags & SA_SIGINFO)
@@ -498,7 +499,6 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
498{ 499{
499 struct k_sigaction ka; 500 struct k_sigaction ka;
500 int restart_syscall; 501 int restart_syscall;
501 sigset_t *oldset;
502 siginfo_t info; 502 siginfo_t info;
503 int signr; 503 int signr;
504 504
@@ -523,11 +523,6 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
523 if (pt_regs_is_syscall(regs) && (regs->psr & PSR_C)) 523 if (pt_regs_is_syscall(regs) && (regs->psr & PSR_C))
524 regs->u_regs[UREG_G6] = orig_i0; 524 regs->u_regs[UREG_G6] = orig_i0;
525 525
526 if (test_thread_flag(TIF_RESTORE_SIGMASK))
527 oldset = &current->saved_sigmask;
528 else
529 oldset = &current->blocked;
530
531 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 526 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
532 527
533 /* If the debugger messes with the program counter, it clears 528 /* If the debugger messes with the program counter, it clears
@@ -544,7 +539,7 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
544 if (signr > 0) { 539 if (signr > 0) {
545 if (restart_syscall) 540 if (restart_syscall)
546 syscall_restart(orig_i0, regs, &ka.sa); 541 syscall_restart(orig_i0, regs, &ka.sa);
547 if (handle_signal(signr, &ka, &info, oldset, regs) == 0) { 542 if (handle_signal(signr, &ka, &info, regs) == 0) {
548 /* a signal was successfully delivered; the saved 543 /* a signal was successfully delivered; the saved
549 * sigmask will have been stored in the signal frame, 544 * sigmask will have been stored in the signal frame,
550 * and will be restored by sigreturn, so we can simply 545 * and will be restored by sigreturn, so we can simply
diff --git a/arch/sparc/kernel/signal_64.c b/arch/sparc/kernel/signal_64.c
index 55b820ee0ac9..088a733f83f9 100644
--- a/arch/sparc/kernel/signal_64.c
+++ b/arch/sparc/kernel/signal_64.c
@@ -512,7 +512,7 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
512{ 512{
513 struct k_sigaction ka; 513 struct k_sigaction ka;
514 int restart_syscall; 514 int restart_syscall;
515 sigset_t *oldset; 515 sigset_t *oldset = sigmask_to_save();
516 siginfo_t info; 516 siginfo_t info;
517 int signr; 517 int signr;
518 518
@@ -538,11 +538,6 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
538 (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY))) 538 (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY)))
539 regs->u_regs[UREG_G6] = orig_i0; 539 regs->u_regs[UREG_G6] = orig_i0;
540 540
541 if (current_thread_info()->status & TS_RESTORE_SIGMASK)
542 oldset = &current->saved_sigmask;
543 else
544 oldset = &current->blocked;
545
546#ifdef CONFIG_COMPAT 541#ifdef CONFIG_COMPAT
547 if (test_thread_flag(TIF_32BIT)) { 542 if (test_thread_flag(TIF_32BIT)) {
548 extern void do_signal32(sigset_t *, struct pt_regs *); 543 extern void do_signal32(sigset_t *, struct pt_regs *);
diff --git a/arch/tile/kernel/signal.c b/arch/tile/kernel/signal.c
index 62b3493ea77d..588c28b2db58 100644
--- a/arch/tile/kernel/signal.c
+++ b/arch/tile/kernel/signal.c
@@ -243,9 +243,10 @@ give_sigsegv:
243 */ 243 */
244 244
245static int handle_signal(unsigned long sig, siginfo_t *info, 245static int handle_signal(unsigned long sig, siginfo_t *info,
246 struct k_sigaction *ka, sigset_t *oldset, 246 struct k_sigaction *ka,
247 struct pt_regs *regs) 247 struct pt_regs *regs)
248{ 248{
249 sigset_t *oldset = sigmask_to_save();
249 int ret; 250 int ret;
250 251
251 /* Are we from a system call? */ 252 /* Are we from a system call? */
@@ -299,7 +300,6 @@ void do_signal(struct pt_regs *regs)
299 siginfo_t info; 300 siginfo_t info;
300 int signr; 301 int signr;
301 struct k_sigaction ka; 302 struct k_sigaction ka;
302 sigset_t *oldset;
303 303
304 /* 304 /*
305 * i386 will check if we're coming from kernel mode and bail out 305 * i386 will check if we're coming from kernel mode and bail out
@@ -308,15 +308,10 @@ void do_signal(struct pt_regs *regs)
308 * helpful, we can reinstate the check on "!user_mode(regs)". 308 * helpful, we can reinstate the check on "!user_mode(regs)".
309 */ 309 */
310 310
311 if (current_thread_info()->status & TS_RESTORE_SIGMASK)
312 oldset = &current->saved_sigmask;
313 else
314 oldset = &current->blocked;
315
316 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 311 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
317 if (signr > 0) { 312 if (signr > 0) {
318 /* Whee! Actually deliver the signal. */ 313 /* Whee! Actually deliver the signal. */
319 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { 314 if (handle_signal(signr, &info, &ka, regs) == 0) {
320 /* 315 /*
321 * A signal was successfully delivered; the saved 316 * A signal was successfully delivered; the saved
322 * sigmask will have been stored in the signal frame, 317 * sigmask will have been stored in the signal frame,
diff --git a/arch/um/kernel/signal.c b/arch/um/kernel/signal.c
index 6acf13c1740b..909e9b8d6612 100644
--- a/arch/um/kernel/signal.c
+++ b/arch/um/kernel/signal.c
@@ -23,9 +23,9 @@ EXPORT_SYMBOL(unblock_signals);
23 * OK, we're invoking a handler 23 * OK, we're invoking a handler
24 */ 24 */
25static int handle_signal(struct pt_regs *regs, unsigned long signr, 25static int handle_signal(struct pt_regs *regs, unsigned long signr,
26 struct k_sigaction *ka, siginfo_t *info, 26 struct k_sigaction *ka, siginfo_t *info)
27 sigset_t *oldset)
28{ 27{
28 sigset_t *oldset = sigmask_to_save();
29 unsigned long sp; 29 unsigned long sp;
30 int err; 30 int err;
31 31
@@ -77,14 +77,9 @@ static int kern_do_signal(struct pt_regs *regs)
77 int sig, handled_sig = 0; 77 int sig, handled_sig = 0;
78 78
79 while ((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0) { 79 while ((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0) {
80 sigset_t *oldset;
81 if (test_thread_flag(TIF_RESTORE_SIGMASK))
82 oldset = &current->saved_sigmask;
83 else
84 oldset = &current->blocked;
85 handled_sig = 1; 80 handled_sig = 1;
86 /* Whee! Actually deliver the signal. */ 81 /* Whee! Actually deliver the signal. */
87 if (!handle_signal(regs, sig, &ka_copy, &info, oldset)) { 82 if (!handle_signal(regs, sig, &ka_copy, &info)) {
88 /* 83 /*
89 * a signal was successfully delivered; the saved 84 * a signal was successfully delivered; the saved
90 * sigmask will have been stored in the signal frame, 85 * sigmask will have been stored in the signal frame,
diff --git a/arch/unicore32/kernel/signal.c b/arch/unicore32/kernel/signal.c
index 65a5ed3b6f2a..bf23194dc74d 100644
--- a/arch/unicore32/kernel/signal.c
+++ b/arch/unicore32/kernel/signal.c
@@ -313,12 +313,11 @@ static inline void setup_syscall_restart(struct pt_regs *regs)
313 * OK, we're invoking a handler 313 * OK, we're invoking a handler
314 */ 314 */
315static int handle_signal(unsigned long sig, struct k_sigaction *ka, 315static int handle_signal(unsigned long sig, struct k_sigaction *ka,
316 siginfo_t *info, sigset_t *oldset, 316 siginfo_t *info, struct pt_regs *regs, int syscall)
317 struct pt_regs *regs, int syscall)
318{ 317{
319 struct thread_info *thread = current_thread_info(); 318 struct thread_info *thread = current_thread_info();
320 struct task_struct *tsk = current; 319 struct task_struct *tsk = current;
321 sigset_t blocked; 320 sigset_t *oldset = sigmask_to_save();
322 int usig = sig; 321 int usig = sig;
323 int ret; 322 int ret;
324 323
@@ -404,13 +403,7 @@ static void do_signal(struct pt_regs *regs, int syscall)
404 403
405 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 404 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
406 if (signr > 0) { 405 if (signr > 0) {
407 sigset_t *oldset; 406 if (handle_signal(signr, &ka, &info, regs, syscall)
408
409 if (test_thread_flag(TIF_RESTORE_SIGMASK))
410 oldset = &current->saved_sigmask;
411 else
412 oldset = &current->blocked;
413 if (handle_signal(signr, &ka, &info, oldset, regs, syscall)
414 == 0) { 407 == 0) {
415 /* 408 /*
416 * A signal was successfully delivered; the saved 409 * A signal was successfully delivered; the saved
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index 25a4a81a51aa..56f3062c5111 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -647,12 +647,9 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
647 struct pt_regs *regs) 647 struct pt_regs *regs)
648{ 648{
649 int usig = signr_convert(sig); 649 int usig = signr_convert(sig);
650 sigset_t *set = &current->blocked; 650 sigset_t *set = sigmask_to_save();
651 int ret; 651 int ret;
652 652
653 if (current_thread_info()->status & TS_RESTORE_SIGMASK)
654 set = &current->saved_sigmask;
655
656 /* Set up the stack frame */ 653 /* Set up the stack frame */
657 if (is_ia32) { 654 if (is_ia32) {
658 if (ka->sa.sa_flags & SA_SIGINFO) 655 if (ka->sa.sa_flags & SA_SIGINFO)
diff --git a/arch/xtensa/kernel/signal.c b/arch/xtensa/kernel/signal.c
index 8c4e751e3b83..e4b06e2d4eb9 100644
--- a/arch/xtensa/kernel/signal.c
+++ b/arch/xtensa/kernel/signal.c
@@ -452,16 +452,10 @@ static void do_signal(struct pt_regs *regs)
452 siginfo_t info; 452 siginfo_t info;
453 int signr; 453 int signr;
454 struct k_sigaction ka; 454 struct k_sigaction ka;
455 sigset_t oldset;
456 455
457 if (try_to_freeze()) 456 if (try_to_freeze())
458 goto no_signal; 457 goto no_signal;
459 458
460 if (test_thread_flag(TIF_RESTORE_SIGMASK))
461 oldset = &current->saved_sigmask;
462 else
463 oldset = &current->blocked;
464
465 task_pt_regs(current)->icountlevel = 0; 459 task_pt_regs(current)->icountlevel = 0;
466 460
467 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 461 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
@@ -501,7 +495,7 @@ static void do_signal(struct pt_regs *regs)
501 495
502 /* Whee! Actually deliver the signal. */ 496 /* Whee! Actually deliver the signal. */
503 /* Set up the stack frame */ 497 /* Set up the stack frame */
504 ret = setup_frame(signr, &ka, &info, oldset, regs); 498 ret = setup_frame(signr, &ka, &info, sigmask_to_save(), regs);
505 if (ret) 499 if (ret)
506 return; 500 return;
507 501