block_sigmask() helper function
Subsystems (2)
cover block_sigmask() helper function
From: Matt Fleming <[email protected]>
Hi Andrew,
Oleg doesn't have a repo on kernel.org yet and suggested that you might take these patches through your -mm tree? Ideally I'd like to get these two in for the 3.3 merge window because I've got a bunch of other patches that can go through the respective maintainers' trees once these two have been merged.
These two patches have been posted before (along with the other 40) but I attempted to get them all merged in one go, which didn't really work. The original thread is here,
https://lkml.org/lkml/2011/8/19/411
Matt Fleming (2):
sparc: Make SA_NOMASK a synonym of SA_NODEFER
signal: Add block_sigmask() for adding sigmask to current->blocked
arch/sparc/include/asm/signal.h | 3 ++- arch/x86/kernel/signal.c | 6 +----- include/linux/signal.h | 1 + kernel/signal.c | 21 +++++++++++++++++++++ 4 files changed, 25 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.4.4
PATCH 1/2 sparc: Make SA_NOMASK a synonym of SA_NODEFER
From: Matt Fleming <[email protected]>
Unlike other architectures, sparc currently has no SA_NODEFER definition but only the older SA_NOMASK. Since SA_NOMASK is the historical name for SA_NODEFER, add SA_NODEFER and copy what other architectures do by making SA_NOMASK a synonym for SA_NODEFER.
--- arch/sparc/include/asm/signal.h | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
arch/sparc/include/asm/signal.h +2 -1
@@ -143,10 +143,11 @@ struct sigstack {#define SA_ONSTACK _SV_SSTACK#define SA_RESTART _SV_INTR#define SA_ONESHOT _SV_RESET -#define SA_NOMASK 0x20u +#define SA_NODEFER 0x20u#define SA_NOCLDWAIT 0x100u#define SA_SIGINFO 0x200u +#define SA_NOMASK SA_NODEFER#define SIG_BLOCK 0x01/* for blocking signals */ #define SIG_UNBLOCK 0x02/* for unblocking signals */
Signature · 1 line
1.7.4.4
Re: [PATCH 1/2] sparc: Make SA_NOMASK a synonym of SA_NODEFER
From: Matt Fleming <[email protected]>
Date: Wed, 21 Dec 2011 18:47:00 +0000
Quoted 11 lines
From: Matt Fleming <[email protected]>
Unlike other architectures, sparc currently has no
SA_NODEFERdefinition but only the olderSA_NOMASK. SinceSA_NOMASKis the historical name forSA_NODEFER, addSA_NODEFERand copy what other architectures do by makingSA_NOMASKa synonym forSA_NODEFER.Cc Oleg Nesterov <[email protected]>Cc "David S. Miller" <[email protected]>Signed-off-by Matt Fleming <[email protected]>
Re: [PATCH 1/2] sparc: Make SA_NOMASK a synonym of SA_NODEFER
In reply to Matt FlemingQuoted 5 lines · Matt Fleming
Unlike other architectures, sparc currently has no
SA_NODEFERdefinition but only the olderSA_NOMASK. SinceSA_NOMASKis the historical name forSA_NODEFER, addSA_NODEFERand copy what other architectures do by makingSA_NOMASKa synonym forSA_NODEFER.
Without this patch arch/sparc can't use the new helper from 2/2
Quoted 28 lines
Cc Oleg Nesterov <[email protected]>Cc "David S. Miller" <[email protected]>Signed-off-by Matt Fleming <[email protected]>--- arch/sparc/include/asm/signal.h | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)arch/sparc/include/asm/signal.h +2
-1@@ -143,10 +143,11 @@ struct sigstack {#define SA_ONSTACK _SV_SSTACK#define SA_RESTART _SV_INTR#define SA_ONESHOT _SV_RESET -#define SA_NOMASK 0x20u +#define SA_NODEFER 0x20u#define SA_NOCLDWAIT 0x100u#define SA_SIGINFO 0x200u +#define SA_NOMASK SA_NODEFER#define SIG_BLOCK 0x01/* for blocking signals */ #define SIG_UNBLOCK 0x02/* for unblocking signals */ Signature · 1 line
1.7.4.4
PATCH 2/2 signal: Add block_sigmask() for adding sigmask to current->blocked
In reply to Matt FlemingFrom: Matt Fleming <[email protected]>
This patch abstracts 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.
--- arch/x86/kernel/signal.c | 6 +----- include/linux/signal.h | 1 + kernel/signal.c | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-)
arch/x86/kernel/signal.c +1 -5
@@ -682,7 +682,6 @@ static int handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, struct pt_regs *regs) { -sigset_t blocked;int ret;/* Are we from a system call? */
@@ -733,10 +732,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,*/ regs->flags &= ~X86_EFLAGS_TF ; -sigorsets (&blocked, ¤t->blocked, &ka->sa.sa_mask); -if (!(ka->sa.sa_flags &SA_NODEFER )) -sigaddset (&blocked, sig); -set_current_blocked (&blocked); +block_sigmask (ka, sig);tracehook_signal_handler (sig, info, ka, regs,test_thread_flag (TIF_SINGLESTEP ));
include/linux/signal.h +1 -0
@@ -254,6 +254,7 @@ extern void set_current_blocked(const sigset_t *);extern int show_unhandled_signals;extern int get_signal_to_deliver (siginfo_t *info,struct k_sigaction *return_ka,struct pt_regs *regs,void *cookie); +extern void block_sigmask (struct k_sigaction *ka,int signr);extern void exit_signals (struct task_struct *tsk);extern struct kmem_cache *sighand_cachep;
kernel/signal.c +21 -0
@@ -2322,6 +2322,27 @@ relock:return signr; } +/** +* block_sigmask - add @ka's signal mask to current->blocked +* @ka: action for @signr +* @signr: signal that has been successfully delivered +* +* This function should be called when a signal has succesfully been +* delivered. It adds the mask of signals for @ka to current->blocked +* so that they are blocked during the execution of the signal +* handler. In addition, @signr will be blocked unless %SA_NODEFER is +* set in @ka->sa.sa_flags. +*/ +void block_sigmask (struct k_sigaction *ka,int signr) +{ +sigset_t blocked; + +sigorsets (&blocked, ¤t->blocked, &ka->sa.sa_mask); +if (!(ka->sa.sa_flags &SA_NODEFER )) +sigaddset (&blocked, signr); +set_current_blocked (&blocked); +} +/* * It could be that complete_signal() picked us to notify about the * group-wide signal. Other threads should be notified now to take
Signature · 1 line
1.7.4.4
Re: [PATCH 2/2] signal: Add block_sigmask() for adding sigmask to current->blocked
Quoted 9 lines · Matt Fleming
From: Matt Fleming <[email protected]>
This patch abstracts the code sequence for adding a signal handler's
sa_masktocurrent->blockedbecause 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.
Quoted 7 lines
Cc Oleg Nesterov <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Tejun Heo <[email protected]>Cc Andrew Morton <[email protected]>Signed-off-by Matt Fleming <[email protected]>
Quoted 77 lines
--- arch/x86/kernel/signal.c | 6 +----- include/linux/signal.h | 1 + kernel/signal.c | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-)arch/x86/kernel/signal.c +1
-5@@ -682,7 +682,6 @@ static int handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka, struct pt_regs *regs) { -sigset_t blocked;int ret;/* Are we from a system call? */ @@ -733,10 +732,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,*/ regs->flags &= ~X86_EFLAGS_TF ; -sigorsets (&blocked, ¤t->blocked, &ka->sa.sa_mask); -if (!(ka->sa.sa_flags &SA_NODEFER )) -sigaddset (&blocked, sig); -set_current_blocked (&blocked); +block_sigmask (ka, sig);tracehook_signal_handler (sig, info, ka, regs,test_thread_flag (TIF_SINGLESTEP ));include/linux/signal.h +1
-0@@ -254,6 +254,7 @@ extern void set_current_blocked(const sigset_t *);extern int show_unhandled_signals;extern int get_signal_to_deliver (siginfo_t *info,struct k_sigaction *return_ka,struct pt_regs *regs,void *cookie); +extern void block_sigmask (struct k_sigaction *ka,int signr);extern void exit_signals (struct task_struct *tsk);extern struct kmem_cache *sighand_cachep;kernel/signal.c +21
-1@@ -2322,6 +2322,27 @@ relock:return signr; } +/** +* block_sigmask - add @ka's signal mask to current->blocked +* @ka: action for @signr +* @signr: signal that has been successfully delivered +* +* This function should be called when a signal has succesfully been +* delivered. It adds the mask of signals for @ka to current->blocked +* so that they are blocked during the execution of the signal +* handler. In addition, @signr will be blocked unless %SA_NODEFER is +* set in @ka->sa.sa_flags. +*/ +void block_sigmask (struct k_sigaction *ka,int signr) +{ +sigset_t blocked; + +sigorsets (&blocked, ¤t->blocked, &ka->sa.sa_mask); +if (!(ka->sa.sa_flags &SA_NODEFER )) +sigaddset (&blocked, signr); +set_current_blocked (&blocked); +} +/* * It could be that complete_signal() picked us to notify about the * group-wide signal. Other threads should be notified now to take -- 1.7.4.4
Quoted 5 lines · Matt Fleming
Hi Andrew,
Oleg doesn't have a repo on kernel.org yet and suggested that you might take these patches through your -mm tree?
Yes, could you take this please? I have no idea when I will restore my korg account. If ever :/
Quoted 4 lines
Ideally I'd like to
get these two in for the 3.3 merge window because I've got a bunch of other patches that can go through the respective maintainers' trees once these two have been merged.
I was surpised by how many bugs there are in arch/ signal code, this patch helps to factor out the code in the signal-deliver paths.
Oleg.