diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-06-01 14:53:44 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-06-01 14:53:44 -0400 |
commit | 86c47b70f62a7072d441ba212aab33c2f82627c2 (patch) | |
tree | d03988bd2226966352bb7f3c2e82ff545353d2c4 /arch/sh | |
parent | 1193755ac6328ad240ba987e6ec41d5e8baf0680 (diff) | |
parent | 44fbbb3dc687c9709a6f2236197316e5c79ab1eb (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal
Pull third pile of signal handling patches from Al Viro:
"This time it's mostly helpers and conversions to them; there's a lot
of stuff remaining in the tree, but that'll either go in -rc2
(isolated bug fixes, ideally via arch maintainers' trees) or will sit
there until the next cycle."
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal:
x86: get rid of calling do_notify_resume() when returning to kernel mode
blackfin: check __get_user() return value
whack-a-mole with TIF_FREEZE
FRV: Optimise the system call exit path in entry.S [ver #2]
FRV: Shrink TIF_WORK_MASK [ver #2]
FRV: Prevent syscall exit tracing and notify_resume at end of kernel exceptions
new helper: signal_delivered()
powerpc: get rid of restore_sigmask()
most of set_current_blocked() callers want SIGKILL/SIGSTOP removed from set
set_restore_sigmask() is never called without SIGPENDING (and never should be)
TIF_RESTORE_SIGMASK can be set only when TIF_SIGPENDING is set
don't call try_to_freeze() from do_signal()
pull clearing RESTORE_SIGMASK into block_sigmask()
sh64: failure to build sigframe != signal without handler
openrisc: tracehook_signal_handler() is supposed to be called on success
new helper: sigmask_to_save()
new helper: restore_saved_sigmask()
new helpers: {clear,test,test_and_clear}_restore_sigmask()
HAVE_RESTORE_SIGMASK is defined on all architectures now
Diffstat (limited to 'arch/sh')
-rw-r--r-- | arch/sh/include/asm/thread_info.h | 19 | ||||
-rw-r--r-- | arch/sh/kernel/signal_32.c | 43 | ||||
-rw-r--r-- | arch/sh/kernel/signal_64.c | 47 |
3 files changed, 39 insertions, 70 deletions
diff --git a/arch/sh/include/asm/thread_info.h b/arch/sh/include/asm/thread_info.h index 0c04ffc4f12c..bc13b57cdc83 100644 --- a/arch/sh/include/asm/thread_info.h +++ b/arch/sh/include/asm/thread_info.h | |||
@@ -169,7 +169,7 @@ static inline void set_restore_sigmask(void) | |||
169 | { | 169 | { |
170 | struct thread_info *ti = current_thread_info(); | 170 | struct thread_info *ti = current_thread_info(); |
171 | ti->status |= TS_RESTORE_SIGMASK; | 171 | ti->status |= TS_RESTORE_SIGMASK; |
172 | set_bit(TIF_SIGPENDING, (unsigned long *)&ti->flags); | 172 | WARN_ON(!test_bit(TIF_SIGPENDING, (unsigned long *)&ti->flags)); |
173 | } | 173 | } |
174 | 174 | ||
175 | #define TI_FLAG_FAULT_CODE_SHIFT 24 | 175 | #define TI_FLAG_FAULT_CODE_SHIFT 24 |
@@ -189,6 +189,23 @@ static inline unsigned int get_thread_fault_code(void) | |||
189 | struct thread_info *ti = current_thread_info(); | 189 | struct thread_info *ti = current_thread_info(); |
190 | return ti->flags >> TI_FLAG_FAULT_CODE_SHIFT; | 190 | return ti->flags >> TI_FLAG_FAULT_CODE_SHIFT; |
191 | } | 191 | } |
192 | |||
193 | static inline void clear_restore_sigmask(void) | ||
194 | { | ||
195 | current_thread_info()->status &= ~TS_RESTORE_SIGMASK; | ||
196 | } | ||
197 | static inline bool test_restore_sigmask(void) | ||
198 | { | ||
199 | return current_thread_info()->status & TS_RESTORE_SIGMASK; | ||
200 | } | ||
201 | static inline bool test_and_clear_restore_sigmask(void) | ||
202 | { | ||
203 | struct thread_info *ti = current_thread_info(); | ||
204 | if (!(ti->status & TS_RESTORE_SIGMASK)) | ||
205 | return false; | ||
206 | ti->status &= ~TS_RESTORE_SIGMASK; | ||
207 | return true; | ||
208 | } | ||
192 | #endif /* !__ASSEMBLY__ */ | 209 | #endif /* !__ASSEMBLY__ */ |
193 | 210 | ||
194 | #endif /* __KERNEL__ */ | 211 | #endif /* __KERNEL__ */ |
diff --git a/arch/sh/kernel/signal_32.c b/arch/sh/kernel/signal_32.c index 9d7bfd66f189..d6b7b6154f87 100644 --- a/arch/sh/kernel/signal_32.c +++ b/arch/sh/kernel/signal_32.c | |||
@@ -32,8 +32,6 @@ | |||
32 | #include <asm/syscalls.h> | 32 | #include <asm/syscalls.h> |
33 | #include <asm/fpu.h> | 33 | #include <asm/fpu.h> |
34 | 34 | ||
35 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) | ||
36 | |||
37 | struct fdpic_func_descriptor { | 35 | struct fdpic_func_descriptor { |
38 | unsigned long text; | 36 | unsigned long text; |
39 | unsigned long GOT; | 37 | unsigned long GOT; |
@@ -226,7 +224,6 @@ asmlinkage int sys_sigreturn(unsigned long r4, unsigned long r5, | |||
226 | sizeof(frame->extramask)))) | 224 | sizeof(frame->extramask)))) |
227 | goto badframe; | 225 | goto badframe; |
228 | 226 | ||
229 | sigdelsetmask(&set, ~_BLOCKABLE); | ||
230 | set_current_blocked(&set); | 227 | set_current_blocked(&set); |
231 | 228 | ||
232 | if (restore_sigcontext(regs, &frame->sc, &r0)) | 229 | if (restore_sigcontext(regs, &frame->sc, &r0)) |
@@ -256,7 +253,6 @@ asmlinkage int sys_rt_sigreturn(unsigned long r4, unsigned long r5, | |||
256 | if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set))) | 253 | if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set))) |
257 | goto badframe; | 254 | goto badframe; |
258 | 255 | ||
259 | sigdelsetmask(&set, ~_BLOCKABLE); | ||
260 | set_current_blocked(&set); | 256 | set_current_blocked(&set); |
261 | 257 | ||
262 | if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0)) | 258 | if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0)) |
@@ -522,10 +518,11 @@ handle_syscall_restart(unsigned long save_r0, struct pt_regs *regs, | |||
522 | /* | 518 | /* |
523 | * OK, we're invoking a handler | 519 | * OK, we're invoking a handler |
524 | */ | 520 | */ |
525 | static int | 521 | static void |
526 | handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, | 522 | handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, |
527 | sigset_t *oldset, struct pt_regs *regs, unsigned int save_r0) | 523 | struct pt_regs *regs, unsigned int save_r0) |
528 | { | 524 | { |
525 | sigset_t *oldset = sigmask_to_save(); | ||
529 | int ret; | 526 | int ret; |
530 | 527 | ||
531 | /* Set up the stack frame */ | 528 | /* Set up the stack frame */ |
@@ -534,10 +531,10 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, | |||
534 | else | 531 | else |
535 | ret = setup_frame(sig, ka, oldset, regs); | 532 | ret = setup_frame(sig, ka, oldset, regs); |
536 | 533 | ||
537 | if (ret == 0) | 534 | if (ret) |
538 | block_sigmask(ka, sig); | 535 | return; |
539 | 536 | signal_delivered(sig, info, ka, regs, | |
540 | return ret; | 537 | test_thread_flag(TIF_SINGLESTEP)); |
541 | } | 538 | } |
542 | 539 | ||
543 | /* | 540 | /* |
@@ -554,7 +551,6 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0) | |||
554 | siginfo_t info; | 551 | siginfo_t info; |
555 | int signr; | 552 | int signr; |
556 | struct k_sigaction ka; | 553 | struct k_sigaction ka; |
557 | sigset_t *oldset; | ||
558 | 554 | ||
559 | /* | 555 | /* |
560 | * We want the common case to go fast, which | 556 | * We want the common case to go fast, which |
@@ -565,30 +561,12 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0) | |||
565 | if (!user_mode(regs)) | 561 | if (!user_mode(regs)) |
566 | return; | 562 | return; |
567 | 563 | ||
568 | if (current_thread_info()->status & TS_RESTORE_SIGMASK) | ||
569 | oldset = ¤t->saved_sigmask; | ||
570 | else | ||
571 | oldset = ¤t->blocked; | ||
572 | |||
573 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); | 564 | signr = get_signal_to_deliver(&info, &ka, regs, NULL); |
574 | if (signr > 0) { | 565 | if (signr > 0) { |
575 | handle_syscall_restart(save_r0, regs, &ka.sa); | 566 | handle_syscall_restart(save_r0, regs, &ka.sa); |
576 | 567 | ||
577 | /* Whee! Actually deliver the signal. */ | 568 | /* Whee! Actually deliver the signal. */ |
578 | if (handle_signal(signr, &ka, &info, oldset, | 569 | handle_signal(signr, &ka, &info, regs, save_r0); |
579 | regs, save_r0) == 0) { | ||
580 | /* | ||
581 | * A signal was successfully delivered; the saved | ||
582 | * sigmask will have been stored in the signal frame, | ||
583 | * and will be restored by sigreturn, so we can simply | ||
584 | * clear the TS_RESTORE_SIGMASK flag | ||
585 | */ | ||
586 | current_thread_info()->status &= ~TS_RESTORE_SIGMASK; | ||
587 | |||
588 | tracehook_signal_handler(signr, &info, &ka, regs, | ||
589 | test_thread_flag(TIF_SINGLESTEP)); | ||
590 | } | ||
591 | |||
592 | return; | 570 | return; |
593 | } | 571 | } |
594 | 572 | ||
@@ -610,10 +588,7 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0) | |||
610 | * If there's no signal to deliver, we just put the saved sigmask | 588 | * If there's no signal to deliver, we just put the saved sigmask |
611 | * back. | 589 | * back. |
612 | */ | 590 | */ |
613 | if (current_thread_info()->status & TS_RESTORE_SIGMASK) { | 591 | restore_saved_sigmask(); |
614 | current_thread_info()->status &= ~TS_RESTORE_SIGMASK; | ||
615 | sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL); | ||
616 | } | ||
617 | } | 592 | } |
618 | 593 | ||
619 | asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int save_r0, | 594 | asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int save_r0, |
diff --git a/arch/sh/kernel/signal_64.c b/arch/sh/kernel/signal_64.c index aa6428430842..6b5b3dfe886b 100644 --- a/arch/sh/kernel/signal_64.c +++ b/arch/sh/kernel/signal_64.c | |||
@@ -41,11 +41,9 @@ | |||
41 | 41 | ||
42 | #define DEBUG_SIG 0 | 42 | #define DEBUG_SIG 0 |
43 | 43 | ||
44 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) | 44 | static void |
45 | |||
46 | static int | ||
47 | handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | 45 | handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, |
48 | sigset_t *oldset, struct pt_regs * regs); | 46 | struct pt_regs * regs); |
49 | 47 | ||
50 | static inline void | 48 | static inline void |
51 | handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa) | 49 | handle_syscall_restart(struct pt_regs *regs, struct sigaction *sa) |
@@ -88,7 +86,6 @@ static void do_signal(struct pt_regs *regs) | |||
88 | siginfo_t info; | 86 | siginfo_t info; |
89 | int signr; | 87 | int signr; |
90 | struct k_sigaction ka; | 88 | struct k_sigaction ka; |
91 | sigset_t *oldset; | ||
92 | 89 | ||
93 | /* | 90 | /* |
94 | * We want the common case to go fast, which | 91 | * We want the common case to go fast, which |
@@ -99,28 +96,13 @@ static void do_signal(struct pt_regs *regs) | |||
99 | if (!user_mode(regs)) | 96 | if (!user_mode(regs)) |
100 | return; | 97 | return; |
101 | 98 | ||
102 | if (current_thread_info()->status & TS_RESTORE_SIGMASK) | ||
103 | oldset = ¤t->saved_sigmask; | ||
104 | else | ||
105 | oldset = ¤t->blocked; | ||
106 | |||
107 | signr = get_signal_to_deliver(&info, &ka, regs, 0); | 99 | signr = get_signal_to_deliver(&info, &ka, regs, 0); |
108 | if (signr > 0) { | 100 | if (signr > 0) { |
109 | handle_syscall_restart(regs, &ka.sa); | 101 | handle_syscall_restart(regs, &ka.sa); |
110 | 102 | ||
111 | /* Whee! Actually deliver the signal. */ | 103 | /* Whee! Actually deliver the signal. */ |
112 | if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { | 104 | handle_signal(signr, &info, &ka, regs); |
113 | /* | 105 | return; |
114 | * If a signal was successfully delivered, the | ||
115 | * saved sigmask is in its frame, and we can | ||
116 | * clear the TS_RESTORE_SIGMASK flag. | ||
117 | */ | ||
118 | current_thread_info()->status &= ~TS_RESTORE_SIGMASK; | ||
119 | |||
120 | tracehook_signal_handler(signr, &info, &ka, regs, | ||
121 | test_thread_flag(TIF_SINGLESTEP)); | ||
122 | return; | ||
123 | } | ||
124 | } | 106 | } |
125 | 107 | ||
126 | /* Did we come from a system call? */ | 108 | /* Did we come from a system call? */ |
@@ -143,12 +125,7 @@ static void do_signal(struct pt_regs *regs) | |||
143 | } | 125 | } |
144 | 126 | ||
145 | /* No signal to deliver -- put the saved sigmask back */ | 127 | /* No signal to deliver -- put the saved sigmask back */ |
146 | if (current_thread_info()->status & TS_RESTORE_SIGMASK) { | 128 | restore_saved_sigmask(); |
147 | current_thread_info()->status &= ~TS_RESTORE_SIGMASK; | ||
148 | sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL); | ||
149 | } | ||
150 | |||
151 | return; | ||
152 | } | 129 | } |
153 | 130 | ||
154 | /* | 131 | /* |
@@ -351,7 +328,6 @@ asmlinkage int sys_sigreturn(unsigned long r2, unsigned long r3, | |||
351 | sizeof(frame->extramask)))) | 328 | sizeof(frame->extramask)))) |
352 | goto badframe; | 329 | goto badframe; |
353 | 330 | ||
354 | sigdelsetmask(&set, ~_BLOCKABLE); | ||
355 | set_current_blocked(&set); | 331 | set_current_blocked(&set); |
356 | 332 | ||
357 | if (restore_sigcontext(regs, &frame->sc, &ret)) | 333 | if (restore_sigcontext(regs, &frame->sc, &ret)) |
@@ -384,7 +360,6 @@ asmlinkage int sys_rt_sigreturn(unsigned long r2, unsigned long r3, | |||
384 | if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set))) | 360 | if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set))) |
385 | goto badframe; | 361 | goto badframe; |
386 | 362 | ||
387 | sigdelsetmask(&set, ~_BLOCKABLE); | ||
388 | set_current_blocked(&set); | 363 | set_current_blocked(&set); |
389 | 364 | ||
390 | if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ret)) | 365 | if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ret)) |
@@ -659,10 +634,11 @@ give_sigsegv: | |||
659 | /* | 634 | /* |
660 | * OK, we're invoking a handler | 635 | * OK, we're invoking a handler |
661 | */ | 636 | */ |
662 | static int | 637 | static void |
663 | handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | 638 | handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, |
664 | sigset_t *oldset, struct pt_regs * regs) | 639 | struct pt_regs * regs) |
665 | { | 640 | { |
641 | sigset_t *oldset = sigmask_to_save(); | ||
666 | int ret; | 642 | int ret; |
667 | 643 | ||
668 | /* Set up the stack frame */ | 644 | /* Set up the stack frame */ |
@@ -671,10 +647,11 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, | |||
671 | else | 647 | else |
672 | ret = setup_frame(sig, ka, oldset, regs); | 648 | ret = setup_frame(sig, ka, oldset, regs); |
673 | 649 | ||
674 | if (ret == 0) | 650 | if (ret) |
675 | block_sigmask(ka, sig); | 651 | return; |
676 | 652 | ||
677 | return ret; | 653 | signal_delivered(sig, info, ka, regs, |
654 | test_thread_flag(TIF_SINGLESTEP)); | ||
678 | } | 655 | } |
679 | 656 | ||
680 | asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags) | 657 | asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags) |