aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-01-10 18:11:17 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 19:30:54 -0500
commit5e6292c0f28f03dfdb8ea3d685f0b838a23bfba4 (patch)
tree8684833680054ab48f9da2bbc36c93e3d00a3391
parentf350b1778f1b7713ef54fbc7e079e09e2fe098b9 (diff)
signal: add block_sigmask() for adding sigmask to current->blocked
Abstract the code sequence for adding a signal handler's sa_mask to current->blocked because the sequence is identical for all architectures. Furthermore, in the past some architectures actually got this code wrong, so introduce a wrapper that all architectures can use. Signed-off-by: Matt Fleming <matt.fleming@intel.com> Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@elte.hu> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Tejun Heo <tj@kernel.org> Cc: "David S. Miller" <davem@davemloft.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/x86/kernel/signal.c6
-rw-r--r--include/linux/signal.h1
-rw-r--r--kernel/signal.c21
3 files changed, 23 insertions, 5 deletions
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index 54ddaeb221c1..46a01bdc27e2 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -682,7 +682,6 @@ static int
682handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, 682handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
683 struct pt_regs *regs) 683 struct pt_regs *regs)
684{ 684{
685 sigset_t blocked;
686 int ret; 685 int ret;
687 686
688 /* Are we from a system call? */ 687 /* Are we from a system call? */
@@ -733,10 +732,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
733 */ 732 */
734 regs->flags &= ~X86_EFLAGS_TF; 733 regs->flags &= ~X86_EFLAGS_TF;
735 734
736 sigorsets(&blocked, &current->blocked, &ka->sa.sa_mask); 735 block_sigmask(ka, sig);
737 if (!(ka->sa.sa_flags & SA_NODEFER))
738 sigaddset(&blocked, sig);
739 set_current_blocked(&blocked);
740 736
741 tracehook_signal_handler(sig, info, ka, regs, 737 tracehook_signal_handler(sig, info, ka, regs,
742 test_thread_flag(TIF_SINGLESTEP)); 738 test_thread_flag(TIF_SINGLESTEP));
diff --git a/include/linux/signal.h b/include/linux/signal.h
index a822300a253b..7987ce74874b 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -254,6 +254,7 @@ extern void set_current_blocked(const sigset_t *);
254extern int show_unhandled_signals; 254extern int show_unhandled_signals;
255 255
256extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie); 256extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
257extern void block_sigmask(struct k_sigaction *ka, int signr);
257extern void exit_signals(struct task_struct *tsk); 258extern void exit_signals(struct task_struct *tsk);
258 259
259extern struct kmem_cache *sighand_cachep; 260extern struct kmem_cache *sighand_cachep;
diff --git a/kernel/signal.c b/kernel/signal.c
index bb0efa5705ed..d532f1709fbf 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2318,6 +2318,27 @@ relock:
2318 return signr; 2318 return signr;
2319} 2319}
2320 2320
2321/**
2322 * block_sigmask - add @ka's signal mask to current->blocked
2323 * @ka: action for @signr
2324 * @signr: signal that has been successfully delivered
2325 *
2326 * This function should be called when a signal has succesfully been
2327 * delivered. It adds the mask of signals for @ka to current->blocked
2328 * so that they are blocked during the execution of the signal
2329 * handler. In addition, @signr will be blocked unless %SA_NODEFER is
2330 * set in @ka->sa.sa_flags.
2331 */
2332void block_sigmask(struct k_sigaction *ka, int signr)
2333{
2334 sigset_t blocked;
2335
2336 sigorsets(&blocked, &current->blocked, &ka->sa.sa_mask);
2337 if (!(ka->sa.sa_flags & SA_NODEFER))
2338 sigaddset(&blocked, signr);
2339 set_current_blocked(&blocked);
2340}
2341
2321/* 2342/*
2322 * It could be that complete_signal() picked us to notify about the 2343 * It could be that complete_signal() picked us to notify about the
2323 * group-wide signal. Other threads should be notified now to take 2344 * group-wide signal. Other threads should be notified now to take