All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask()
@ 2011-08-19 16:46 Matt Fleming
  2011-08-19 16:46 ` [PATCH 01/43] signal: Add block_sigmask() for adding sigmask to current->blocked Matt Fleming
                   ` (43 more replies)
  0 siblings, 44 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel

From: Matt Fleming <matt.fleming@intel.com>

Hi Oleg,

This v2 includes block_sigmask(). You'll have to take the "Use
set_current_blocked() and block_sigmask()" patches in your tree once
the architecture maintainers have Acked them because they all now
depend on the first patch in the series "signal: Add block_sigmask()
for adding sigmask to current->blocked", so if arch maintainers were
to take them in their separate trees they'd introduce compiler
breakage. In fact, it's probably worth just taking this entire series
into one tree. Also, because I can't Cc all the maintainers in this
one email (I counted 45 different email addresses!) I've included
information in their patches.

If you need help with the git tree stuff just let me know, or I can
gather all the ACKs and then send you a pull request. We'll work
something out.

I did a tree wide scan of all the code that modifies current->blocked
without using the set_current_blocked() accessor. This patch series is
the result of the conversion to the new accessor functions.

This series also helps to reduce the complexity of my signal
scalability patches that I posted in April, because we now have much
fewer callers of recalc_sigpending() (the signal scalability patches
introduce a new lock that needs to be held when calling
recalc_sigpending()).

This series is available in the 'oleg/set-current-blocked-v2' branch at,

    git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/linux-2.6.git

P.S I've punted on fully converting ia64 to set_current_blocked()
because bits of the signal code are written in asm. I'll follow up
with a later patch that does the conversion once I've improved my ia64
foo (or coerced Tony Luck into doing it ;).

Matt Fleming (42):
  signal: Add block_sigmask() for adding sigmask to current->blocked
  alpha: Use set_current_blocked() and block_sigmask()
  arm: Use set_current_blocked() and block_sigmask()
  avr32: Don't mask signals in the error path
  avr32: Use block_sigmask()
  blackfin: Use set_current_blocked() and block_sigmask()
  cris: Use set_current_blocked() and block_sigmask()
  frv: Use set_current_blocked() and block_sigmask()
  h8300: Use set_current_blocked() and block_sigmask()
  ia64: Use set_current_blocked() and block_sigmask()
  m32r: Use set_current_blocked() and block_sigmask()
  m68k: Use set_current_blocked() and block_sigmask()
  microblaze: Don't reimplement force_sigsegv()
  microblaze: No need to reset handler if SA_ONESHOT
  microblaze: Fix signal masking
  microblaze: Use set_current_blocked() and block_sigmask()
  MIPS: Use set_current_blocked() and block_sigmask()
  mn10300: Use set_current_blocked() and block_sigmask()
  OpenRISC: Don't reimplement force_sigsegv()
  OpenRISC: No need to reset handler if SA_ONESHOT
  OpenRISC: Don't mask signals if we fail to setup signal stack
  OpenRISC: Use set_current_blocked() and block_sigmask()
  parisc: Use set_current_blocked() and block_sigmask()
  powerpc: Use set_current_blocked() and block_sigmask()
  [S390]: Use block_sigmask()
  score: Don't mask signals if we fail to setup signal stack
  score: Use set_current_blocked() and block_sigmask()
  sh: No need to reset handler if SA_ONESHOT
  sh: Use set_current_blocked() and block_sigmask()
  sparc: Use set_current_blocked() and block_sigmask()
  tile: Use set_current_blocked() and block_sigmask()
  um: Use set_current_blocked() and block_sigmask()
  um: Don't restore current->blocked on error
  unicore32: Use set_current_blocked() and block_sigmask()
  xtensa: Don't reimplement force_sigsegv()
  xtensa: No need to reset handler if SA_ONESHOT
  xtensa: Don't mask signals if we fail to setup signal stack
  xtensa: Use set_current_blocked() and block_sigmask()
  autofs4: Use set_current_blocked()
  coda: Use set_current_blocked()
  dlm: Remove another superfluous call to recalc_sigpending()
  ncpfs: Use set_current_blocked()

Oleg Nesterov (1):
  avr32: use set_current_blocked() in handle_signal/sys_rt_sigreturn

 arch/alpha/kernel/signal.c         |   31 ++++++++----------------
 arch/arm/kernel/signal.c           |   24 ++++++------------
 arch/avr32/kernel/signal.c         |   26 ++++++--------------
 arch/blackfin/kernel/signal.c      |   17 +++----------
 arch/cris/arch-v10/kernel/signal.c |   34 +++++++++-----------------
 arch/cris/arch-v32/kernel/signal.c |   37 ++++++++--------------------
 arch/frv/kernel/signal.c           |   32 ++++++++-----------------
 arch/h8300/kernel/signal.c         |   33 +++++++-------------------
 arch/ia64/kernel/signal.c          |   15 +----------
 arch/m32r/kernel/signal.c          |   12 +--------
 arch/m68k/kernel/signal_mm.c       |   22 +++++++----------
 arch/m68k/kernel/signal_no.c       |   28 +++++++---------------
 arch/microblaze/kernel/signal.c    |   42 +++++++++++++--------------------
 arch/mips/kernel/signal.c          |   27 ++++-----------------
 arch/mips/kernel/signal32.c        |   20 +++------------
 arch/mips/kernel/signal_n32.c      |   10 +------
 arch/mn10300/kernel/signal.c       |   32 ++++++++-----------------
 arch/openrisc/kernel/signal.c      |   45 +++++++++++++++--------------------
 arch/parisc/kernel/signal.c        |   12 +--------
 arch/powerpc/kernel/signal.c       |   13 +--------
 arch/powerpc/kernel/signal_32.c    |   11 ++++----
 arch/s390/kernel/compat_signal.c   |    6 +----
 arch/s390/kernel/signal.c          |    6 +----
 arch/score/kernel/signal.c         |   13 ++--------
 arch/sh/kernel/signal_32.c         |   35 ++++++++--------------------
 arch/sh/kernel/signal_64.c         |   40 ++++++++------------------------
 arch/sparc/kernel/signal32.c       |   17 ++-----------
 arch/sparc/kernel/signal_32.c      |   28 +++++++---------------
 arch/sparc/kernel/signal_64.c      |   29 ++++++++---------------
 arch/tile/kernel/compat_signal.c   |    5 +---
 arch/tile/kernel/signal.c          |   13 +--------
 arch/um/kernel/signal.c            |   28 +++++++---------------
 arch/um/sys-i386/signal.c          |   12 +--------
 arch/um/sys-x86_64/signal.c        |    6 +----
 arch/unicore32/kernel/signal.c     |   13 +--------
 arch/x86/kernel/signal.c           |    6 +----
 arch/xtensa/kernel/signal.c        |   35 ++++++++-------------------
 fs/autofs4/waitq.c                 |   13 +++-------
 fs/coda/upcall.c                   |   19 ++++++--------
 fs/dlm/user.c                      |    1 -
 fs/ncpfs/sock.c                    |   15 ++++--------
 include/linux/signal.h             |    1 +
 kernel/signal.c                    |   21 ++++++++++++++++
 43 files changed, 276 insertions(+), 609 deletions(-)

-- 
1.7.4.4


^ permalink raw reply	[flat|nested] 71+ messages in thread

* [PATCH 01/43] signal: Add block_sigmask() for adding sigmask to current->blocked
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-22 10:19   ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 02/43] alpha: Use set_current_blocked() and block_sigmask() Matt Fleming
                   ` (42 subsequent siblings)
  43 siblings, 1 reply; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: linux-kernel, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	Tejun Heo, Andrew Morton

From: Matt Fleming <matt.fleming@intel.com>

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.

Cc: 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 arch/x86/kernel/signal.c |    6 +-----
 include/linux/signal.h   |    1 +
 kernel/signal.c          |   21 +++++++++++++++++++++
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index 54ddaeb2..46a01bd 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -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, &current->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));
diff --git a/include/linux/signal.h b/include/linux/signal.h
index a822300..7987ce74 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -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;
diff --git a/kernel/signal.c b/kernel/signal.c
index 291c970..7a08164 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2314,6 +2314,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, &current->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


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 02/43] alpha: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
  2011-08-19 16:46 ` [PATCH 01/43] signal: Add block_sigmask() for adding sigmask to current->blocked Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 03/43] arm: " Matt Fleming
                   ` (41 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: linux-kernel, Richard Henderson, Ivan Kokshaysky, Matt Turner, Al Viro

From: Matt Fleming <matt.fleming@linux.intel.com>

As described in e6fa16ab ("signal: sigprocmask() should do
retarget_shared_pending()") the modification of current->blocked is
incorrect as we need to check for shared signals we're about to block.

Also, use the new helper function block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/alpha/kernel/signal.c |   31 ++++++++++---------------------
 1 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/arch/alpha/kernel/signal.c b/arch/alpha/kernel/signal.c
index 6f7feb5..35f2ef4 100644
--- a/arch/alpha/kernel/signal.c
+++ b/arch/alpha/kernel/signal.c
@@ -120,12 +120,13 @@ SYSCALL_DEFINE5(rt_sigaction, int, sig, const struct sigaction __user *, act,
  */
 SYSCALL_DEFINE1(sigsuspend, old_sigset_t, mask)
 {
-	mask &= _BLOCKABLE;
-	spin_lock_irq(&current->sighand->siglock);
+	sigset_t blocked;
+
 	current->saved_sigmask = current->blocked;
-	siginitset(&current->blocked, mask);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+
+	mask &= _BLOCKABLE;
+	siginitset(&blocked, mask);
+	set_current_blocked(&blocked);
 
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
@@ -238,10 +239,7 @@ do_sigreturn(struct sigcontext __user *sc, struct pt_regs *regs,
 		goto give_sigsegv;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(sc, regs, sw))
 		goto give_sigsegv;
@@ -276,10 +274,7 @@ do_rt_sigreturn(struct rt_sigframe __user *frame, struct pt_regs *regs,
 		goto give_sigsegv;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(&frame->uc.uc_mcontext, regs, sw))
 		goto give_sigsegv;
@@ -501,14 +496,8 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
 	else
 		ret = setup_frame(sig, ka, oldset, regs, sw);
 
-	if (ret == 0) {
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
-		if (!(ka->sa.sa_flags & SA_NODEFER)) 
-			sigaddset(&current->blocked,sig);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
-	}
+	if (ret == 0)
+		block_sigmask(ka, sig);
 
 	return ret;
 }
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 03/43] arm: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
  2011-08-19 16:46 ` [PATCH 01/43] signal: Add block_sigmask() for adding sigmask to current->blocked Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 02/43] alpha: Use set_current_blocked() and block_sigmask() Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-25 17:15   ` Will Deacon
  2011-08-19 16:46 ` [PATCH v2 04/43] avr32: Don't mask signals in the error path Matt Fleming
                   ` (40 subsequent siblings)
  43 siblings, 1 reply; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: linux-kernel, Russell King, Arnd Bergmann, Dave Martin,
	Nicolas Pitre, Will Deacon

From: Matt Fleming <matt.fleming@linux.intel.com>

As described in e6fa16ab ("signal: sigprocmask() should do
retarget_shared_pending()") the modification of current->blocked is
incorrect as we need to check for shared signals we're about to block.

Also, use the new helper function block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Arnd Bergmann <arnd.bergmann@linaro.org>
Cc: Dave Martin <dave.martin@linaro.org>
Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

Will, I dropped your Acked-by because I felt this patch changed quite
dramatically since v1 and warrants another review. I hope that's OK.

 arch/arm/kernel/signal.c |   24 ++++++++----------------
 1 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index 0340224..d13e61a 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -66,12 +66,13 @@ const unsigned long syscall_restart_code[2] = {
  */
 asmlinkage int sys_sigsuspend(int restart, unsigned long oldmask, old_sigset_t mask)
 {
-	mask &= _BLOCKABLE;
-	spin_lock_irq(&current->sighand->siglock);
+	sigset_t blocked;
+
 	current->saved_sigmask = current->blocked;
-	siginitset(&current->blocked, mask);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+
+	mask &= _BLOCKABLE;
+	siginitset(&blocked, mask);
+	set_current_blocked(&blocked);
 
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
@@ -281,10 +282,7 @@ static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
 	err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set));
 	if (err == 0) {
 		sigdelsetmask(&set, ~_BLOCKABLE);
-		spin_lock_irq(&current->sighand->siglock);
-		current->blocked = set;
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
+		set_current_blocked(&set);
 	}
 
 	__get_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err);
@@ -637,13 +635,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
 	/*
 	 * Block the signal if we were successful.
 	 */
-	spin_lock_irq(&tsk->sighand->siglock);
-	sigorsets(&tsk->blocked, &tsk->blocked,
-		  &ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&tsk->blocked, sig);
-	recalc_sigpending();
-	spin_unlock_irq(&tsk->sighand->siglock);
+	block_sigmask(ka, sig);
 
 	return 0;
 }
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 04/43] avr32: Don't mask signals in the error path
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (2 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 03/43] arm: " Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 05/43] avr32: use set_current_blocked() in handle_signal/sys_rt_sigreturn Matt Fleming
                   ` (39 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Hans-Christian Egtvedt

From: Matt Fleming <matt.fleming@linux.intel.com>

The current handle_signal() implementation is broken - it will mask
signals if we fail to setup the signal stack frame, which isn't the
desired behaviour, we should only be masking signals if we succeed in
setting up the stack frame. It looks like this code was copied from
the old (broken) arm implementation but wasn't updated when the arm
code was fixed in commit a6c61e9dfdd0 ("[ARM] 3168/1: Update ARM
signal delivery and masking").

Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Acked-by: Havard Skinnemoen <hskinnemoen@gmail.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
---
 arch/avr32/kernel/signal.c |   25 ++++++++++++-------------
 1 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/arch/avr32/kernel/signal.c b/arch/avr32/kernel/signal.c
index 64f886f..9c075e1 100644
--- a/arch/avr32/kernel/signal.c
+++ b/arch/avr32/kernel/signal.c
@@ -238,22 +238,21 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
 	 */
 	ret |= !valid_user_regs(regs);
 
+	if (ret != 0) {
+		force_sigsegv(sig, current);
+		return;
+	}
+
 	/*
-	 * Block the signal if we were unsuccessful.
+	 * Block the signal if we were successful.
 	 */
-	if (ret != 0 || !(ka->sa.sa_flags & SA_NODEFER)) {
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked, &current->blocked,
-			  &ka->sa.sa_mask);
+	spin_lock_irq(&current->sighand->siglock);
+	sigorsets(&current->blocked, &current->blocked,
+		  &ka->sa.sa_mask);
+	if (!(ka->sa.sa_flags & SA_NODEFER))
 		sigaddset(&current->blocked, sig);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
-	}
-
-	if (ret == 0)
-		return;
-
-	force_sigsegv(sig, current);
+	recalc_sigpending();
+	spin_unlock_irq(&current->sighand->siglock);
 }
 
 /*
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 05/43] avr32: use set_current_blocked() in handle_signal/sys_rt_sigreturn
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (3 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 04/43] avr32: Don't mask signals in the error path Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 06/43] avr32: Use block_sigmask() Matt Fleming
                   ` (38 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Hans-Christian Egtvedt

From: Oleg Nesterov <oleg@redhat.com>

It is wrong to change ->blocked directly, see e6fa16ab.
Change  handle_signal() and sys_rt_sigreturn() to use
the right helper, set_current_blocked().

Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Acked-by: Havard Skinnemoen <hskinnemoen@gmail.com>
Reviewed-by: Matt Fleming <matt.fleming@intel.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 arch/avr32/kernel/signal.c |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/arch/avr32/kernel/signal.c b/arch/avr32/kernel/signal.c
index 9c075e1..06f4293 100644
--- a/arch/avr32/kernel/signal.c
+++ b/arch/avr32/kernel/signal.c
@@ -87,10 +87,7 @@ asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
 		goto badframe;
@@ -226,6 +223,7 @@ static inline void
 handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
 	      sigset_t *oldset, struct pt_regs *regs, int syscall)
 {
+	sigset_t blocked;
 	int ret;
 
 	/*
@@ -246,13 +244,10 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
 	/*
 	 * Block the signal if we were successful.
 	 */
-	spin_lock_irq(&current->sighand->siglock);
-	sigorsets(&current->blocked, &current->blocked,
-		  &ka->sa.sa_mask);
+	sigorsets(&blocked, &current->blocked, &ka->sa.sa_mask);
 	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&current->blocked, sig);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+		sigaddset(&blocked, sig);
+	set_current_blocked(&blocked);
 }
 
 /*
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 06/43] avr32: Use block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (4 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 05/43] avr32: use set_current_blocked() in handle_signal/sys_rt_sigreturn Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 07/43] blackfin: Use set_current_blocked() and block_sigmask() Matt Fleming
                   ` (37 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Hans-Christian Egtvedt, Havard Skinnemoen

From: Matt Fleming <matt.fleming@intel.com>

Use the new helper function block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Cc: Havard Skinnemoen <hskinnemoen@gmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/avr32/kernel/signal.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/arch/avr32/kernel/signal.c b/arch/avr32/kernel/signal.c
index 06f4293..feeb77b 100644
--- a/arch/avr32/kernel/signal.c
+++ b/arch/avr32/kernel/signal.c
@@ -223,7 +223,6 @@ static inline void
 handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
 	      sigset_t *oldset, struct pt_regs *regs, int syscall)
 {
-	sigset_t blocked;
 	int ret;
 
 	/*
@@ -244,10 +243,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
 	/*
 	 * Block the signal if we were successful.
 	 */
-	sigorsets(&blocked, &current->blocked, &ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&blocked, sig);
-	set_current_blocked(&blocked);
+	block_sigmask(ka, sig);
 }
 
 /*
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 07/43] blackfin: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (5 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 06/43] avr32: Use block_sigmask() Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-20  4:00   ` Mike Frysinger
  2011-08-19 16:46 ` [PATCH v2 08/43] cris: " Matt Fleming
                   ` (36 subsequent siblings)
  43 siblings, 1 reply; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Mike Frysinger

From: Matt Fleming <matt.fleming@linux.intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/blackfin/kernel/signal.c |   17 ++++-------------
 1 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/arch/blackfin/kernel/signal.c b/arch/blackfin/kernel/signal.c
index d536f35..05ece02 100644
--- a/arch/blackfin/kernel/signal.c
+++ b/arch/blackfin/kernel/signal.c
@@ -99,10 +99,7 @@ asmlinkage int do_rt_sigreturn(unsigned long __unused)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (rt_restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0))
 		goto badframe;
@@ -266,15 +263,9 @@ handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
 	/* set up the stack frame */
 	ret = setup_rt_frame(sig, ka, info, oldset, regs);
 
-	if (ret == 0) {
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked, &current->blocked,
-			  &ka->sa.sa_mask);
-		if (!(ka->sa.sa_flags & SA_NODEFER))
-			sigaddset(&current->blocked, sig);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
-	}
+	if (ret == 0)
+		block_sigmask(ka, sig);
+
 	return ret;
 }
 
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 08/43] cris: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (6 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 07/43] blackfin: Use set_current_blocked() and block_sigmask() Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 09/43] frv: " Matt Fleming
                   ` (35 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Mikael Starvik, Jesper Nilsson

From: Matt Fleming <matt.fleming@linux.intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/cris/arch-v10/kernel/signal.c |   34 +++++++++++---------------------
 arch/cris/arch-v32/kernel/signal.c |   37 ++++++++++-------------------------
 2 files changed, 23 insertions(+), 48 deletions(-)

diff --git a/arch/cris/arch-v10/kernel/signal.c b/arch/cris/arch-v10/kernel/signal.c
index e78fe49..a6e1ff0 100644
--- a/arch/cris/arch-v10/kernel/signal.c
+++ b/arch/cris/arch-v10/kernel/signal.c
@@ -50,12 +50,14 @@ void do_signal(int canrestart, struct pt_regs *regs);
 int sys_sigsuspend(old_sigset_t mask, long r11, long r12, long r13, long mof,
 	long srp, struct pt_regs *regs)
 {
-	mask &= _BLOCKABLE;
-	spin_lock_irq(&current->sighand->siglock);
+	sigset_t blocked;
+
 	current->saved_sigmask = current->blocked;
-	siginitset(&current->blocked, mask);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+
+	mask &= _BLOCKABLE;
+	siginitset(&blocked, mask);
+	set_current_blocked(&blocked);
+
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
 	set_thread_flag(TIF_RESTORE_SIGMASK);
@@ -184,10 +186,7 @@ asmlinkage int sys_sigreturn(long r10, long r11, long r12, long r13, long mof,
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(regs, &frame->sc))
 		goto badframe;
@@ -223,10 +222,7 @@ asmlinkage int sys_rt_sigreturn(long r10, long r11, long r12, long r13,
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
 		goto badframe;
@@ -468,15 +464,9 @@ static inline int handle_signal(int canrestart, unsigned long sig,
 	else
 		ret = setup_frame(sig, ka, oldset, regs);
 
-	if (ret == 0) {
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked, &current->blocked,
-			&ka->sa.sa_mask);
-		if (!(ka->sa.sa_flags & SA_NODEFER))
-			sigaddset(&current->blocked, sig);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
-	}
+	if (ret == 0)
+		block_sigmask(ka, sig);
+
 	return ret;
 }
 
diff --git a/arch/cris/arch-v32/kernel/signal.c b/arch/cris/arch-v32/kernel/signal.c
index ce4ab1a..e7ea1ea 100644
--- a/arch/cris/arch-v32/kernel/signal.c
+++ b/arch/cris/arch-v32/kernel/signal.c
@@ -62,12 +62,14 @@ int
 sys_sigsuspend(old_sigset_t mask, long r11, long r12, long r13, long mof,
 	       long srp, struct pt_regs *regs)
 {
-	mask &= _BLOCKABLE;
-	spin_lock_irq(&current->sighand->siglock);
+	sigset_t blocked;
+
 	current->saved_sigmask = current->blocked;
-	siginitset(&current->blocked, mask);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+
+	mask &= _BLOCKABLE;
+	siginitset(&blocked, mask);
+	set_current_blocked(&blocked);
+
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
 	set_thread_flag(TIF_RESTORE_SIGMASK);
@@ -176,12 +178,7 @@ sys_sigreturn(long r10, long r11, long r12, long r13, long mof, long srp,
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-
-	current->blocked = set;
-
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(regs, &frame->sc))
 		goto badframe;
@@ -222,12 +219,7 @@ sys_rt_sigreturn(long r10, long r11, long r12, long r13, long mof, long srp,
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-
-	current->blocked = set;
-
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
 		goto badframe;
@@ -515,15 +507,8 @@ handle_signal(int canrestart, unsigned long sig,
 	if (ka->sa.sa_flags & SA_ONESHOT)
 		ka->sa.sa_handler = SIG_DFL;
 
-	if (ret == 0) {
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked, &current->blocked,
-			&ka->sa.sa_mask);
-		if (!(ka->sa.sa_flags & SA_NODEFER))
-			sigaddset(&current->blocked, sig);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
-	}
+	if (ret == 0)
+		block_sigmask(ka, sig);
 
 	return ret;
 }
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 09/43] frv: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (7 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 08/43] cris: " Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 10/43] h8300: " Matt Fleming
                   ` (34 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, David Howells, Al Viro

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/frv/kernel/signal.c |   32 ++++++++++----------------------
 1 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/arch/frv/kernel/signal.c b/arch/frv/kernel/signal.c
index bab0129..dfa460e 100644
--- a/arch/frv/kernel/signal.c
+++ b/arch/frv/kernel/signal.c
@@ -40,12 +40,13 @@ struct fdpic_func_descriptor {
  */
 asmlinkage int sys_sigsuspend(int history0, int history1, old_sigset_t mask)
 {
-	mask &= _BLOCKABLE;
-	spin_lock_irq(&current->sighand->siglock);
+	sigset_t blocked;
+
 	current->saved_sigmask = current->blocked;
-	siginitset(&current->blocked, mask);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+
+	mask &= _BLOCKABLE;
+	siginitset(&blocked, mask);
+	set_current_blocked(&blocked);
 
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
@@ -158,10 +159,7 @@ asmlinkage int sys_sigreturn(void)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(&frame->sc, &gr8))
 		goto badframe;
@@ -184,10 +182,7 @@ asmlinkage int sys_rt_sigreturn(void)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(&frame->uc.uc_mcontext, &gr8))
 		goto badframe;
@@ -474,15 +469,8 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
 	else
 		ret = setup_frame(sig, ka, oldset);
 
-	if (ret == 0) {
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked, &current->blocked,
-			  &ka->sa.sa_mask);
-		if (!(ka->sa.sa_flags & SA_NODEFER))
-			sigaddset(&current->blocked, sig);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
-	}
+	if (ret == 0)
+		block_sigmask(ka, sig);
 
 	return ret;
 
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 10/43] h8300: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (8 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 09/43] frv: " Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 11/43] ia64: " Matt Fleming
                   ` (33 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Yoshinori Sato

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/h8300/kernel/signal.c |   33 +++++++++------------------------
 1 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/arch/h8300/kernel/signal.c b/arch/h8300/kernel/signal.c
index af842c3..cd63f5a 100644
--- a/arch/h8300/kernel/signal.c
+++ b/arch/h8300/kernel/signal.c
@@ -57,14 +57,13 @@ asmlinkage int do_signal(struct pt_regs *regs, sigset_t *oldset);
 asmlinkage int do_sigsuspend(struct pt_regs *regs)
 {
 	old_sigset_t mask = regs->er3;
-	sigset_t saveset;
+	sigset_t saveset, blocked;
 
-	mask &= _BLOCKABLE;
-	spin_lock_irq(&current->sighand->siglock);
 	saveset = current->blocked;
-	siginitset(&current->blocked, mask);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+
+	mask &= _BLOCKABLE;
+	siginitset(&blocked, mask);
+	set_current_blocked(&blocked);
 
 	regs->er0 = -EINTR;
 	while (1) {
@@ -90,11 +89,8 @@ do_rt_sigsuspend(struct pt_regs *regs)
 		return -EFAULT;
 	sigdelsetmask(&newset, ~_BLOCKABLE);
 
-	spin_lock_irq(&current->sighand->siglock);
 	saveset = current->blocked;
-	current->blocked = newset;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&newset);
 
 	regs->er0 = -EINTR;
 	while (1) {
@@ -232,10 +228,7 @@ asmlinkage int do_sigreturn(unsigned long __unused,...)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 	
 	if (restore_sigcontext(regs, &frame->sc, &er0))
 		goto badframe;
@@ -260,10 +253,7 @@ asmlinkage int do_rt_sigreturn(unsigned long __unused,...)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_unlock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_lock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 	
 	if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &er0))
 		goto badframe;
@@ -489,12 +479,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
 	else
 		setup_frame(sig, ka, oldset, regs);
 
-	spin_lock_irq(&current->sighand->siglock);
-	sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&current->blocked,sig);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	block_sigmask(ka, sig);
 }
 
 /*
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 11/43] ia64: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (9 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 10/43] h8300: " Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 12/43] m32r: " Matt Fleming
                   ` (32 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Tony Luck, Fenghua Yu

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/ia64/kernel/signal.c |   15 ++-------------
 1 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/arch/ia64/kernel/signal.c b/arch/ia64/kernel/signal.c
index 7bdafc8..7523501 100644
--- a/arch/ia64/kernel/signal.c
+++ b/arch/ia64/kernel/signal.c
@@ -201,13 +201,7 @@ ia64_rt_sigreturn (struct sigscratch *scr)
 		goto give_sigsegv;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-
-	spin_lock_irq(&current->sighand->siglock);
-	{
-		current->blocked = set;
-		recalc_sigpending();
-	}
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(sc, scr))
 		goto give_sigsegv;
@@ -427,12 +421,7 @@ handle_signal (unsigned long sig, struct k_sigaction *ka, siginfo_t *info, sigse
 	if (!setup_frame(sig, ka, info, oldset, scr))
 		return 0;
 
-	spin_lock_irq(&current->sighand->siglock);
-	sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&current->blocked, sig);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	block_sigmask(ka, sig);
 
 	/*
 	 * Let tracing know that we've done the handler setup.
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 12/43] m32r: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (10 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 11/43] ia64: " Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 13/43] m68k: " Matt Fleming
                   ` (31 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Hirokazu Takata, Al Viro, Kyle McMartin

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Hirokazu Takata <takata@linux-m32r.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Kyle McMartin <kyle@redhat.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/m32r/kernel/signal.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/arch/m32r/kernel/signal.c b/arch/m32r/kernel/signal.c
index a08697f..f54d969 100644
--- a/arch/m32r/kernel/signal.c
+++ b/arch/m32r/kernel/signal.c
@@ -112,10 +112,7 @@ sys_rt_sigreturn(unsigned long r0, unsigned long r1,
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &result))
 		goto badframe;
@@ -300,12 +297,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
 	if (setup_rt_frame(sig, ka, info, oldset, regs))
 		return -EFAULT;
 
-	spin_lock_irq(&current->sighand->siglock);
-	sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&current->blocked,sig);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	block_sigmask(ka, sig);
 	return 0;
 }
 
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 13/43] m68k: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (11 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 12/43] m32r: " Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-24  4:38   ` Greg Ungerer
  2011-08-19 16:46 ` [PATCH v2 14/43] microblaze: Don't reimplement force_sigsegv() Matt Fleming
                   ` (30 subsequent siblings)
  43 siblings, 1 reply; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Geert Uytterhoeven, Greg Ungerer

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greg Ungerer <gerg@uclinux.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/m68k/kernel/signal_mm.c |   22 +++++++++-------------
 arch/m68k/kernel/signal_no.c |   28 +++++++++-------------------
 2 files changed, 18 insertions(+), 32 deletions(-)

diff --git a/arch/m68k/kernel/signal_mm.c b/arch/m68k/kernel/signal_mm.c
index a0afc23..74ba0cf 100644
--- a/arch/m68k/kernel/signal_mm.c
+++ b/arch/m68k/kernel/signal_mm.c
@@ -97,12 +97,13 @@ int handle_kernel_fault(struct pt_regs *regs)
 asmlinkage int
 sys_sigsuspend(int unused0, int unused1, old_sigset_t mask)
 {
-	mask &= _BLOCKABLE;
-	spin_lock_irq(&current->sighand->siglock);
+	sigset_t blocked;
+
 	current->saved_sigmask = current->blocked;
-	siginitset(&current->blocked, mask);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+
+	mask &= _BLOCKABLE;
+	siginitset(&blocked, mask);
+	set_current_blocked(&blocked);
 
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
@@ -465,8 +466,7 @@ asmlinkage int do_sigreturn(unsigned long __unused)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	current->blocked = set;
-	recalc_sigpending();
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(regs, &frame->sc, frame + 1))
 		goto badframe;
@@ -491,8 +491,7 @@ asmlinkage int do_rt_sigreturn(unsigned long __unused)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	current->blocked = set;
-	recalc_sigpending();
+	set_current_blocked(&set);
 
 	if (rt_restore_ucontext(regs, sw, &frame->uc))
 		goto badframe;
@@ -965,10 +964,7 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
 	if (err)
 		return;
 
-	sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&current->blocked,sig);
-	recalc_sigpending();
+	block_sigmask(ka, sig);
 
 	if (test_thread_flag(TIF_DELAYED_TRACE)) {
 		regs->sr &= ~0x8000;
diff --git a/arch/m68k/kernel/signal_no.c b/arch/m68k/kernel/signal_no.c
index 36a81bb..33e8bf5 100644
--- a/arch/m68k/kernel/signal_no.c
+++ b/arch/m68k/kernel/signal_no.c
@@ -60,12 +60,13 @@ void ret_from_user_rt_signal(void);
 asmlinkage int
 sys_sigsuspend(int unused0, int unused1, old_sigset_t mask)
 {
-	mask &= _BLOCKABLE;
-	spin_lock_irq(&current->sighand->siglock);
+	sigset_t blocked;
+
 	current->saved_sigmask = current->blocked;
-	siginitset(&current->blocked, mask);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+
+	mask &= _BLOCKABLE;
+	siginitset(&blocked, mask);
+	set_current_blocked(&blocked);
 
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
@@ -343,10 +344,7 @@ asmlinkage int do_sigreturn(unsigned long __unused)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 	
 	if (restore_sigcontext(regs, &frame->sc, frame + 1, &d0))
 		goto badframe;
@@ -372,10 +370,7 @@ asmlinkage int do_rt_sigreturn(unsigned long __unused)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 	
 	if (rt_restore_ucontext(regs, sw, &frame->uc, &d0))
 		goto badframe;
@@ -708,12 +703,7 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
 	if (err)
 		return;
 
-	spin_lock_irq(&current->sighand->siglock);
-	sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&current->blocked,sig);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	block_sigmask(ka, sig);
 
 	clear_thread_flag(TIF_RESTORE_SIGMASK);
 }
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 14/43] microblaze: Don't reimplement force_sigsegv()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (12 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 13/43] m68k: " Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 15/43] microblaze: No need to reset handler if SA_ONESHOT Matt Fleming
                   ` (29 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel

From: Matt Fleming <matt.fleming@intel.com>

Instead of open coding the sequence from force_sigsegv() just call
it. This also fixes a bug because we were modifying ka->sa.sa_handler
(which is a copy of sighand->action[]), whereas the intention of the
code was to modify sighand->action[] directly.

As the original code was working with a copy it had no effect on
signal delivery.

Acked-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Michal Simek <monstr@monstr.eu>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 arch/microblaze/kernel/signal.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/arch/microblaze/kernel/signal.c b/arch/microblaze/kernel/signal.c
index 5996711..90de06d 100644
--- a/arch/microblaze/kernel/signal.c
+++ b/arch/microblaze/kernel/signal.c
@@ -270,9 +270,7 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
 	return;
 
 give_sigsegv:
-	if (sig == SIGSEGV)
-		ka->sa.sa_handler = SIG_DFL;
-	force_sig(SIGSEGV, current);
+	force_sigsegv(sig, current);
 }
 
 /* Handle restarting system calls */
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 15/43] microblaze: No need to reset handler if SA_ONESHOT
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (13 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 14/43] microblaze: Don't reimplement force_sigsegv() Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 16/43] microblaze: Fix signal masking Matt Fleming
                   ` (28 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel

From: Matt Fleming <matt.fleming@intel.com>

get_signal_to_deliver() already resets the signal handler if
SA_ONESHOT is set in ka->sa.sa_flags, there's no need to do it again
in handle_signal(). Furthermore, because we were modifying
ka->sa.sa_handler (which is a copy of sighand->action[]) instead of
sighand->action[] the original code actually had no effect on signal
delivery.

Acked-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Michal Simek <monstr@monstr.eu>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 arch/microblaze/kernel/signal.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/arch/microblaze/kernel/signal.c b/arch/microblaze/kernel/signal.c
index 90de06d..9e749c0 100644
--- a/arch/microblaze/kernel/signal.c
+++ b/arch/microblaze/kernel/signal.c
@@ -320,9 +320,6 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
 	else
 		setup_rt_frame(sig, ka, NULL, oldset, regs);
 
-	if (ka->sa.sa_flags & SA_ONESHOT)
-		ka->sa.sa_handler = SIG_DFL;
-
 	if (!(ka->sa.sa_flags & SA_NODEFER)) {
 		spin_lock_irq(&current->sighand->siglock);
 		sigorsets(&current->blocked,
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 16/43] microblaze: Fix signal masking
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (14 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 15/43] microblaze: No need to reset handler if SA_ONESHOT Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 17/43] microblaze: Use set_current_blocked() and block_sigmask() Matt Fleming
                   ` (27 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel

From: Matt Fleming <matt.fleming@intel.com>

There are a couple of problems with the current signal code,

1. If we failed to setup the signal stack frame then we
should not be masking any signals.

2. ka->sa.sa_mask is only added to the current blocked signals list if
SA_NODEFER is set in ka->sa.sa_flags. If we successfully setup the
signal frame and are going to run the handler then we must honour
sa_mask.

Acked-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Michal Simek <monstr@monstr.eu>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 arch/microblaze/kernel/signal.c |   31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/arch/microblaze/kernel/signal.c b/arch/microblaze/kernel/signal.c
index 9e749c0..f2c13d5 100644
--- a/arch/microblaze/kernel/signal.c
+++ b/arch/microblaze/kernel/signal.c
@@ -169,7 +169,7 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
 	return (void __user *)((sp - frame_size) & -8UL);
 }
 
-static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
+static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
 			sigset_t *set, struct pt_regs *regs)
 {
 	struct rt_sigframe __user *frame;
@@ -267,10 +267,11 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
 		current->comm, current->pid, frame, regs->pc);
 #endif
 
-	return;
+	return 0;
 
 give_sigsegv:
 	force_sigsegv(sig, current);
+	return -EFAULT;
 }
 
 /* Handle restarting system calls */
@@ -314,21 +315,25 @@ static int
 handle_signal(unsigned long sig, struct k_sigaction *ka,
 		siginfo_t *info, sigset_t *oldset, struct pt_regs *regs)
 {
+	int ret;
+
 	/* Set up the stack frame */
 	if (ka->sa.sa_flags & SA_SIGINFO)
-		setup_rt_frame(sig, ka, info, oldset, regs);
+		ret = setup_rt_frame(sig, ka, info, oldset, regs);
 	else
-		setup_rt_frame(sig, ka, NULL, oldset, regs);
+		ret = setup_rt_frame(sig, ka, NULL, oldset, regs);
+
+	if (ret)
+		return ret;
 
-	if (!(ka->sa.sa_flags & SA_NODEFER)) {
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked,
-				&current->blocked, &ka->sa.sa_mask);
+	spin_lock_irq(&current->sighand->siglock);
+	sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
+	if (!(ka->sa.sa_flags & SA_NODEFER))
 		sigaddset(&current->blocked, sig);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
-	}
-	return 1;
+	recalc_sigpending();
+	spin_unlock_irq(&current->sighand->siglock);
+
+	return 0;
 }
 
 /*
@@ -369,7 +374,7 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset, int in_syscall)
 		/* Whee! Actually deliver the signal. */
 		if (in_syscall)
 			handle_restart(regs, &ka, 1);
-		if (handle_signal(signr, &ka, &info, oldset, regs)) {
+		if (!handle_signal(signr, &ka, &info, oldset, regs)) {
 			/*
 			 * A signal was successfully delivered; the saved
 			 * sigmask will have been stored in the signal frame,
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 17/43] microblaze: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (15 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 16/43] microblaze: Fix signal masking Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-24  8:49   ` Michal Simek
  2011-08-19 16:46 ` [PATCH v2 18/43] MIPS: " Matt Fleming
                   ` (26 subsequent siblings)
  43 siblings, 1 reply; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Michal Simek

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

Michal, I dropped your Acked-by because I felt this patch changed
quite dramatically since v1 and warrants another review. I hope that's
OK.


 arch/microblaze/kernel/signal.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/arch/microblaze/kernel/signal.c b/arch/microblaze/kernel/signal.c
index f2c13d5..99b9708 100644
--- a/arch/microblaze/kernel/signal.c
+++ b/arch/microblaze/kernel/signal.c
@@ -105,10 +105,7 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &rval))
 		goto badframe;
@@ -326,12 +323,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
 	if (ret)
 		return ret;
 
-	spin_lock_irq(&current->sighand->siglock);
-	sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&current->blocked, sig);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	block_sigmask(ka, sig);
 
 	return 0;
 }
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 18/43] MIPS: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (16 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 17/43] microblaze: Use set_current_blocked() and block_sigmask() Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 17:27   ` Ralf Baechle
  2011-08-19 16:46 ` [PATCH v2 19/43] mn10300: " Matt Fleming
                   ` (25 subsequent siblings)
  43 siblings, 1 reply; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Ralf Baechle, Al Viro, David Daney

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: David Daney <ddaney@caviumnetworks.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/mips/kernel/signal.c     |   27 +++++----------------------
 arch/mips/kernel/signal32.c   |   20 ++++----------------
 arch/mips/kernel/signal_n32.c |   10 ++--------
 3 files changed, 11 insertions(+), 46 deletions(-)

diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
index dbbe0ce..5652808 100644
--- a/arch/mips/kernel/signal.c
+++ b/arch/mips/kernel/signal.c
@@ -255,11 +255,8 @@ asmlinkage int sys_sigsuspend(nabi_no_regargs struct pt_regs regs)
 		return -EFAULT;
 	sigdelsetmask(&newset, ~_BLOCKABLE);
 
-	spin_lock_irq(&current->sighand->siglock);
 	current->saved_sigmask = current->blocked;
-	current->blocked = newset;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&newset);
 
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
@@ -284,11 +281,8 @@ asmlinkage int sys_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
 		return -EFAULT;
 	sigdelsetmask(&newset, ~_BLOCKABLE);
 
-	spin_lock_irq(&current->sighand->siglock);
 	current->saved_sigmask = current->blocked;
-	current->blocked = newset;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&newset);
 
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
@@ -360,10 +354,7 @@ asmlinkage void sys_sigreturn(nabi_no_regargs struct pt_regs regs)
 		goto badframe;
 
 	sigdelsetmask(&blocked, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = blocked;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&blocked);
 
 	sig = restore_sigcontext(&regs, &frame->sf_sc);
 	if (sig < 0)
@@ -399,10 +390,7 @@ asmlinkage void sys_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	sig = restore_sigcontext(&regs, &frame->rs_uc.uc_mcontext);
 	if (sig < 0)
@@ -578,12 +566,7 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
 	if (ret)
 		return ret;
 
-	spin_lock_irq(&current->sighand->siglock);
-	sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&current->blocked, sig);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	block_sigmask(ka, sig);
 
 	return ret;
 }
diff --git a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c
index aae9866..902a889 100644
--- a/arch/mips/kernel/signal32.c
+++ b/arch/mips/kernel/signal32.c
@@ -290,11 +290,8 @@ asmlinkage int sys32_sigsuspend(nabi_no_regargs struct pt_regs regs)
 		return -EFAULT;
 	sigdelsetmask(&newset, ~_BLOCKABLE);
 
-	spin_lock_irq(&current->sighand->siglock);
 	current->saved_sigmask = current->blocked;
-	current->blocked = newset;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&newset);
 
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
@@ -318,11 +315,8 @@ asmlinkage int sys32_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
 		return -EFAULT;
 	sigdelsetmask(&newset, ~_BLOCKABLE);
 
-	spin_lock_irq(&current->sighand->siglock);
 	current->saved_sigmask = current->blocked;
-	current->blocked = newset;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&newset);
 
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
@@ -488,10 +482,7 @@ asmlinkage void sys32_sigreturn(nabi_no_regargs struct pt_regs regs)
 		goto badframe;
 
 	sigdelsetmask(&blocked, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = blocked;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&blocked);
 
 	sig = restore_sigcontext32(&regs, &frame->sf_sc);
 	if (sig < 0)
@@ -529,10 +520,7 @@ asmlinkage void sys32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	sig = restore_sigcontext32(&regs, &frame->rs_uc.uc_mcontext);
 	if (sig < 0)
diff --git a/arch/mips/kernel/signal_n32.c b/arch/mips/kernel/signal_n32.c
index ee24d81..30fc7ff 100644
--- a/arch/mips/kernel/signal_n32.c
+++ b/arch/mips/kernel/signal_n32.c
@@ -94,11 +94,8 @@ asmlinkage int sysn32_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
 	sigset_from_compat(&newset, &uset);
 	sigdelsetmask(&newset, ~_BLOCKABLE);
 
-	spin_lock_irq(&current->sighand->siglock);
 	current->saved_sigmask = current->blocked;
-	current->blocked = newset;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&newset);
 
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
@@ -122,10 +119,7 @@ asmlinkage void sysn32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	sig = restore_sigcontext(&regs, &frame->rs_uc.uc_mcontext);
 	if (sig < 0)
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 19/43] mn10300: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (17 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 18/43] MIPS: " Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 20/43] OpenRISC: Don't reimplement force_sigsegv() Matt Fleming
                   ` (24 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, David Howells, Koichi Yasutake, Al Viro

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/mn10300/kernel/signal.c |   32 ++++++++++----------------------
 1 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/arch/mn10300/kernel/signal.c b/arch/mn10300/kernel/signal.c
index 690f4e9..bd77c6d 100644
--- a/arch/mn10300/kernel/signal.c
+++ b/arch/mn10300/kernel/signal.c
@@ -38,12 +38,13 @@
  */
 asmlinkage long sys_sigsuspend(int history0, int history1, old_sigset_t mask)
 {
-	mask &= _BLOCKABLE;
-	spin_lock_irq(&current->sighand->siglock);
+	sigset_t blocked;
+
 	current->saved_sigmask = current->blocked;
-	siginitset(&current->blocked, mask);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+
+	mask &= _BLOCKABLE;
+	siginitset(&blocked, mask);
+	set_current_blocked(&blocked);
 
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
@@ -172,10 +173,7 @@ asmlinkage long sys_sigreturn(void)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(current_frame(), &frame->sc, &d0))
 		goto badframe;
@@ -203,10 +201,7 @@ asmlinkage long sys_rt_sigreturn(void)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(current_frame(), &frame->uc.uc_mcontext, &d0))
 		goto badframe;
@@ -476,15 +471,8 @@ static int handle_signal(int sig,
 	else
 		ret = setup_frame(sig, ka, oldset, regs);
 
-	if (ret == 0) {
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked, &current->blocked,
-			  &ka->sa.sa_mask);
-		if (!(ka->sa.sa_flags & SA_NODEFER))
-			sigaddset(&current->blocked, sig);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
-	}
+	if (ret == 0)
+		block_sigmask(ka, sig);
 
 	return ret;
 }
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 20/43] OpenRISC: Don't reimplement force_sigsegv()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (18 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 19/43] mn10300: " Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 21/43] OpenRISC: No need to reset handler if SA_ONESHOT Matt Fleming
                   ` (23 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Jonas Bonn, Arnd Bergmann

From: Matt Fleming <matt.fleming@intel.com>

Instead of open coding the sequence from force_sigsegv() just call
it. This also fixes a bug because we were modifying ka->sa.sa_handler
(which is a copy of sighand->action[]), whereas the intention of the
code was to modify sighand->action[] directly.

As the original code was working with a copy it had no effect on
signal delivery.

Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 arch/openrisc/kernel/signal.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/arch/openrisc/kernel/signal.c b/arch/openrisc/kernel/signal.c
index 5f759c7..c023db9 100644
--- a/arch/openrisc/kernel/signal.c
+++ b/arch/openrisc/kernel/signal.c
@@ -257,9 +257,7 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
 	return;
 
 give_sigsegv:
-	if (sig == SIGSEGV)
-		ka->sa.sa_handler = SIG_DFL;
-	force_sig(SIGSEGV, current);
+	force_sigsegv(sig, current);
 }
 
 static inline void
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 21/43] OpenRISC: No need to reset handler if SA_ONESHOT
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (19 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 20/43] OpenRISC: Don't reimplement force_sigsegv() Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 22/43] OpenRISC: Don't mask signals if we fail to setup signal stack Matt Fleming
                   ` (22 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Jonas Bonn, Arnd Bergmann

From: Matt Fleming <matt.fleming@intel.com>

get_signal_to_deliver() already resets the signal handler if
SA_ONESHOT is set in ka->sa.sa_flags, there's no need to do it again
in handle_signal(). Furthermore, because we were modifying
ka->sa.sa_handler (which is a copy of sighand->action[]) instead of
sighand->action[] the original code actually had no effect on signal
delivery.

Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 arch/openrisc/kernel/signal.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/arch/openrisc/kernel/signal.c b/arch/openrisc/kernel/signal.c
index c023db9..2f75e74 100644
--- a/arch/openrisc/kernel/signal.c
+++ b/arch/openrisc/kernel/signal.c
@@ -267,9 +267,6 @@ handle_signal(unsigned long sig,
 {
 	setup_rt_frame(sig, ka, info, oldset, regs);
 
-	if (ka->sa.sa_flags & SA_ONESHOT)
-		ka->sa.sa_handler = SIG_DFL;
-
 	spin_lock_irq(&current->sighand->siglock);
 	sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
 	if (!(ka->sa.sa_flags & SA_NODEFER))
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 22/43] OpenRISC: Don't mask signals if we fail to setup signal stack
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (20 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 21/43] OpenRISC: No need to reset handler if SA_ONESHOT Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 23/43] OpenRISC: Use set_current_blocked() and block_sigmask() Matt Fleming
                   ` (21 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Jonas Bonn, Arnd Bergmann

From: Matt Fleming <matt.fleming@intel.com>

setup_rt_frame() needs to return an indication of whether it succeeded
or failed in setting up the signal stack frame. If setup_rt_frame()
fails then we must not modify current->blocked.

Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 arch/openrisc/kernel/signal.c |   29 ++++++++++++++++++-----------
 1 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/arch/openrisc/kernel/signal.c b/arch/openrisc/kernel/signal.c
index 2f75e74..b0bdfda 100644
--- a/arch/openrisc/kernel/signal.c
+++ b/arch/openrisc/kernel/signal.c
@@ -196,8 +196,8 @@ static inline void __user *get_sigframe(struct k_sigaction *ka,
  * trampoline which performs the syscall sigreturn, or a provided
  * user-mode trampoline.
  */
-static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
-			   sigset_t *set, struct pt_regs *regs)
+static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
+			  sigset_t *set, struct pt_regs *regs)
 {
 	struct rt_sigframe *frame;
 	unsigned long return_ip;
@@ -254,18 +254,23 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
 	/* actually move the usp to reflect the stacked frame */
 	regs->sp = (unsigned long)frame;
 
-	return;
+	return 0;
 
 give_sigsegv:
 	force_sigsegv(sig, current);
+	return -EFAULT;
 }
 
-static inline void
+static inline int
 handle_signal(unsigned long sig,
 	      siginfo_t *info, struct k_sigaction *ka,
 	      sigset_t *oldset, struct pt_regs *regs)
 {
-	setup_rt_frame(sig, ka, info, oldset, regs);
+	int ret;
+
+	ret = setup_rt_frame(sig, ka, info, oldset, regs);
+	if (ret)
+		return ret;
 
 	spin_lock_irq(&current->sighand->siglock);
 	sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
@@ -274,6 +279,8 @@ handle_signal(unsigned long sig,
 	recalc_sigpending();
 
 	spin_unlock_irq(&current->sighand->siglock);
+
+	return 0;
 }
 
 /*
@@ -362,13 +369,13 @@ void do_signal(struct pt_regs *regs)
 			oldset = &current->blocked;
 
 		/* Whee!  Actually deliver the signal.  */
-		handle_signal(signr, &info, &ka, oldset, regs);
-		/* a signal was successfully delivered; the saved
-		 * sigmask will have been stored in the signal frame,
-		 * and will be restored by sigreturn, so we can simply
-		 * clear the TIF_RESTORE_SIGMASK flag */
-		if (test_thread_flag(TIF_RESTORE_SIGMASK))
+		if (!handle_signal(signr, &info, &ka, oldset, regs)) {
+			/* a signal was successfully delivered; the saved
+			 * sigmask will have been stored in the signal frame,
+			 * and will be restored by sigreturn, so we can simply
+			 * clear the TIF_RESTORE_SIGMASK flag */
 			clear_thread_flag(TIF_RESTORE_SIGMASK);
+		}
 
 		tracehook_signal_handler(signr, &info, &ka, regs,
 					 test_thread_flag(TIF_SINGLESTEP));
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 23/43] OpenRISC: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (21 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 22/43] OpenRISC: Don't mask signals if we fail to setup signal stack Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 24/43] parisc: " Matt Fleming
                   ` (20 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Jonas Bonn, Arnd Bergmann

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/openrisc/kernel/signal.c |   13 ++-----------
 1 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/arch/openrisc/kernel/signal.c b/arch/openrisc/kernel/signal.c
index b0bdfda..01ff754 100644
--- a/arch/openrisc/kernel/signal.c
+++ b/arch/openrisc/kernel/signal.c
@@ -108,10 +108,7 @@ asmlinkage long _sys_rt_sigreturn(struct pt_regs *regs)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
 		goto badframe;
@@ -272,13 +269,7 @@ handle_signal(unsigned long sig,
 	if (ret)
 		return ret;
 
-	spin_lock_irq(&current->sighand->siglock);
-	sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&current->blocked, sig);
-	recalc_sigpending();
-
-	spin_unlock_irq(&current->sighand->siglock);
+	block_sigmask(ka, sig);
 
 	return 0;
 }
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 24/43] parisc: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (22 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 23/43] OpenRISC: Use set_current_blocked() and block_sigmask() Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 25/43] powerpc: " Matt Fleming
                   ` (19 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: linux-kernel, Kyle McMartin, Helge Deller, James E.J. Bottomley

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Helge Deller <deller@gmx.de>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/parisc/kernel/signal.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c
index 12c1ed3..bd36152 100644
--- a/arch/parisc/kernel/signal.c
+++ b/arch/parisc/kernel/signal.c
@@ -131,10 +131,7 @@ sys_rt_sigreturn(struct pt_regs *regs, int in_syscall)
 	}
 		
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	/* Good thing we saved the old gr[30], eh? */
 #ifdef CONFIG_64BIT
@@ -454,12 +451,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
 	if (!setup_rt_frame(sig, ka, info, oldset, regs, in_syscall))
 		return 0;
 
-	spin_lock_irq(&current->sighand->siglock);
-	sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&current->blocked,sig);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	block_sigmask(ka, sig);
 
 	tracehook_signal_handler(sig, info, ka, regs, 
 		test_thread_flag(TIF_SINGLESTEP) ||
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 25/43] powerpc: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (23 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 24/43] parisc: " Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH 26/43] [S390]: Use block_sigmask() Matt Fleming
                   ` (18 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Benjamin Herrenschmidt, Paul Mackerras

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/powerpc/kernel/signal.c    |   13 ++-----------
 arch/powerpc/kernel/signal_32.c |   11 ++++++-----
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
index 2300426..3867f7b 100644
--- a/arch/powerpc/kernel/signal.c
+++ b/arch/powerpc/kernel/signal.c
@@ -56,10 +56,7 @@ void __user * get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
 void restore_sigmask(sigset_t *set)
 {
 	sigdelsetmask(set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = *set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(set);
 }
 
 static void check_syscall_restart(struct pt_regs *regs, struct k_sigaction *ka,
@@ -167,13 +164,7 @@ static int do_signal_pending(sigset_t *oldset, struct pt_regs *regs)
 
 	regs->trap = 0;
 	if (ret) {
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked, &current->blocked,
-			  &ka.sa.sa_mask);
-		if (!(ka.sa.sa_flags & SA_NODEFER))
-			sigaddset(&current->blocked, signr);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
+		block_sigmask(&ka, signr);
 
 		/*
 		 * A signal was successfully delivered; the saved sigmask is in
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index 78b76dc..5fc9d19 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -242,12 +242,13 @@ static inline int restore_general_regs(struct pt_regs *regs,
  */
 long sys_sigsuspend(old_sigset_t mask)
 {
-	mask &= _BLOCKABLE;
-	spin_lock_irq(&current->sighand->siglock);
+	sigset_t blocked;
+
 	current->saved_sigmask = current->blocked;
-	siginitset(&current->blocked, mask);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+
+	mask &= _BLOCKABLE;
+	siginitset(&blocked, mask);
+	set_current_blocked(&blocked);
 
  	current->state = TASK_INTERRUPTIBLE;
  	schedule();
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH 26/43] [S390]: Use block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (24 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 25/43] powerpc: " Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-23  6:04   ` Martin Schwidefsky
  2011-08-19 16:46 ` [PATCH v2 27/43] score: Don't mask signals if we fail to setup signal stack Matt Fleming
                   ` (17 subsequent siblings)
  43 siblings, 1 reply; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Martin Schwidefsky, Heiko Carstens

From: Matt Fleming <matt.fleming@intel.com>

Use the new helper function block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

This patch depends on "[PATCH 01/43] signal: Add block_sigmask() for
adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/s390/kernel/compat_signal.c |    6 +-----
 arch/s390/kernel/signal.c        |    6 +-----
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/arch/s390/kernel/compat_signal.c b/arch/s390/kernel/compat_signal.c
index a9a285b..e78415c 100644
--- a/arch/s390/kernel/compat_signal.c
+++ b/arch/s390/kernel/compat_signal.c
@@ -592,7 +592,6 @@ give_sigsegv:
 int handle_signal32(unsigned long sig, struct k_sigaction *ka,
 		    siginfo_t *info, sigset_t *oldset, struct pt_regs *regs)
 {
-	sigset_t blocked;
 	int ret;
 
 	/* Set up the stack frame */
@@ -602,10 +601,7 @@ int handle_signal32(unsigned long sig, struct k_sigaction *ka,
 		ret = setup_frame32(sig, ka, oldset, regs);
 	if (ret)
 		return ret;
-	sigorsets(&blocked, &current->blocked, &ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&blocked, sig);
-	set_current_blocked(&blocked);
+	block_sigmask(ka, sig);
 	return 0;
 }
 
diff --git a/arch/s390/kernel/signal.c b/arch/s390/kernel/signal.c
index 9a40e1c..3564636 100644
--- a/arch/s390/kernel/signal.c
+++ b/arch/s390/kernel/signal.c
@@ -373,7 +373,6 @@ static int handle_signal(unsigned long sig, struct k_sigaction *ka,
 			 siginfo_t *info, sigset_t *oldset,
 			 struct pt_regs *regs)
 {
-	sigset_t blocked;
 	int ret;
 
 	/* Set up the stack frame */
@@ -383,10 +382,7 @@ static int handle_signal(unsigned long sig, struct k_sigaction *ka,
 		ret = setup_frame(sig, ka, oldset, regs);
 	if (ret)
 		return ret;
-	sigorsets(&blocked, &current->blocked, &ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&blocked, sig);
-	set_current_blocked(&blocked);
+	block_sigmask(ka, sig);
 	return 0;
 }
 
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 27/43] score: Don't mask signals if we fail to setup signal stack
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (25 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH 26/43] [S390]: Use block_sigmask() Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 28/43] score: Use set_current_blocked() and block_sigmask() Matt Fleming
                   ` (16 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Chen Liqin, Lennox Wu

From: Matt Fleming <matt.fleming@intel.com>

If setup_rt_frame() returns -EFAULT then we must not block any signals
in the current process.

Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Chen Liqin <liqin.chen@sunplusct.com>
Cc: Lennox Wu <lennox.wu@gmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 arch/score/kernel/signal.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/score/kernel/signal.c b/arch/score/kernel/signal.c
index aa57440..bf9e33e 100644
--- a/arch/score/kernel/signal.c
+++ b/arch/score/kernel/signal.c
@@ -272,12 +272,14 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
 	 */
 	ret = setup_rt_frame(ka, regs, sig, oldset, info);
 
-	spin_lock_irq(&current->sighand->siglock);
-	sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&current->blocked, sig);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	if (ret == 0) {
+		spin_lock_irq(&current->sighand->siglock);
+		sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
+		if (!(ka->sa.sa_flags & SA_NODEFER))
+			sigaddset(&current->blocked, sig);
+		recalc_sigpending();
+		spin_unlock_irq(&current->sighand->siglock);
+	}
 
 	return ret;
 }
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 28/43] score: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (26 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 27/43] score: Don't mask signals if we fail to setup signal stack Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 29/43] sh: No need to reset handler if SA_ONESHOT Matt Fleming
                   ` (15 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Chen Liqin, Lennox Wu

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Chen Liqin <liqin.chen@sunplusct.com>
Cc: Lennox Wu <lennox.wu@gmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/score/kernel/signal.c |   15 +++------------
 1 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/arch/score/kernel/signal.c b/arch/score/kernel/signal.c
index bf9e33e..5a5bd17 100644
--- a/arch/score/kernel/signal.c
+++ b/arch/score/kernel/signal.c
@@ -159,10 +159,7 @@ score_rt_sigreturn(struct pt_regs *regs)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	sig = restore_sigcontext(regs, &frame->rs_uc.uc_mcontext);
 	if (sig < 0)
@@ -272,14 +269,8 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
 	 */
 	ret = setup_rt_frame(ka, regs, sig, oldset, info);
 
-	if (ret == 0) {
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
-		if (!(ka->sa.sa_flags & SA_NODEFER))
-			sigaddset(&current->blocked, sig);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
-	}
+	if (ret == 0)
+		block_sigmask(ka, sig);
 
 	return ret;
 }
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 29/43] sh: No need to reset handler if SA_ONESHOT
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (27 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 28/43] score: Use set_current_blocked() and block_sigmask() Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 30/43] sh: Use set_current_blocked() and block_sigmask() Matt Fleming
                   ` (14 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Paul Mundt

From: Matt Fleming <matt.fleming@intel.com>

get_signal_to_deliver() already resets the signal handler if
SA_ONESHOT is set in ka->sa.sa_flags, there's no need to do it again
in handle_signal(). Furthermore, because we were modifying
ka->sa.sa_handler (which is a copy of sighand->action[]) instead of
sighand->action[] the original code had no effect on signal delivery.

Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 arch/sh/kernel/signal_32.c |    3 ---
 arch/sh/kernel/signal_64.c |    3 ---
 2 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/arch/sh/kernel/signal_32.c b/arch/sh/kernel/signal_32.c
index 579cd2c..7a00304 100644
--- a/arch/sh/kernel/signal_32.c
+++ b/arch/sh/kernel/signal_32.c
@@ -548,9 +548,6 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
 	else
 		ret = setup_frame(sig, ka, oldset, regs);
 
-	if (ka->sa.sa_flags & SA_ONESHOT)
-		ka->sa.sa_handler = SIG_DFL;
-
 	if (ret == 0) {
 		spin_lock_irq(&current->sighand->siglock);
 		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
diff --git a/arch/sh/kernel/signal_64.c b/arch/sh/kernel/signal_64.c
index 5a9f1f1..c0e7d10 100644
--- a/arch/sh/kernel/signal_64.c
+++ b/arch/sh/kernel/signal_64.c
@@ -738,9 +738,6 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
 	else
 		ret = setup_frame(sig, ka, oldset, regs);
 
-	if (ka->sa.sa_flags & SA_ONESHOT)
-		ka->sa.sa_handler = SIG_DFL;
-
 	if (ret == 0) {
 		spin_lock_irq(&current->sighand->siglock);
 		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 30/43] sh: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (28 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 29/43] sh: No need to reset handler if SA_ONESHOT Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 31/43] sparc: " Matt Fleming
                   ` (13 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Paul Mundt

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/sh/kernel/signal_32.c |   32 ++++++++++----------------------
 arch/sh/kernel/signal_64.c |   37 ++++++++++---------------------------
 2 files changed, 20 insertions(+), 49 deletions(-)

diff --git a/arch/sh/kernel/signal_32.c b/arch/sh/kernel/signal_32.c
index 7a00304..68ecb69 100644
--- a/arch/sh/kernel/signal_32.c
+++ b/arch/sh/kernel/signal_32.c
@@ -58,12 +58,13 @@ sys_sigsuspend(old_sigset_t mask,
 	       unsigned long r5, unsigned long r6, unsigned long r7,
 	       struct pt_regs __regs)
 {
-	mask &= _BLOCKABLE;
-	spin_lock_irq(&current->sighand->siglock);
+	sigset_t blocked;
+
 	current->saved_sigmask = current->blocked;
-	siginitset(&current->blocked, mask);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+
+	mask &= _BLOCKABLE;
+	siginitset(&blocked, mask);
+	set_current_blocked(&blocked);
 
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
@@ -240,11 +241,7 @@ asmlinkage int sys_sigreturn(unsigned long r4, unsigned long r5,
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(regs, &frame->sc, &r0))
 		goto badframe;
@@ -274,10 +271,7 @@ asmlinkage int sys_rt_sigreturn(unsigned long r4, unsigned long r5,
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0))
 		goto badframe;
@@ -548,14 +542,8 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
 	else
 		ret = setup_frame(sig, ka, oldset, regs);
 
-	if (ret == 0) {
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
-		if (!(ka->sa.sa_flags & SA_NODEFER))
-			sigaddset(&current->blocked,sig);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
-	}
+	if (ret == 0)
+		block_sigmask(ka, sig);
 
 	return ret;
 }
diff --git a/arch/sh/kernel/signal_64.c b/arch/sh/kernel/signal_64.c
index c0e7d10..cc94365 100644
--- a/arch/sh/kernel/signal_64.c
+++ b/arch/sh/kernel/signal_64.c
@@ -163,14 +163,13 @@ sys_sigsuspend(old_sigset_t mask,
 	       unsigned long r6, unsigned long r7,
 	       struct pt_regs * regs)
 {
-	sigset_t saveset;
+	sigset_t saveset, blocked;
 
-	mask &= _BLOCKABLE;
-	spin_lock_irq(&current->sighand->siglock);
 	saveset = current->blocked;
-	siginitset(&current->blocked, mask);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+
+	mask &= _BLOCKABLE;
+	siginitset(&blocked, mask);
+	set_current_blocked(&blocked);
 
 	REF_REG_RET = -EINTR;
 	while (1) {
@@ -202,11 +201,8 @@ sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize,
 	if (copy_from_user(&newset, unewset, sizeof(newset)))
 		return -EFAULT;
 	sigdelsetmask(&newset, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
 	saveset = current->blocked;
-	current->blocked = newset;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&newset);
 
 	REF_REG_RET = -EINTR;
 	while (1) {
@@ -412,11 +408,7 @@ asmlinkage int sys_sigreturn(unsigned long r2, unsigned long r3,
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(regs, &frame->sc, &ret))
 		goto badframe;
@@ -449,10 +441,7 @@ asmlinkage int sys_rt_sigreturn(unsigned long r2, unsigned long r3,
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &ret))
 		goto badframe;
@@ -738,14 +727,8 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
 	else
 		ret = setup_frame(sig, ka, oldset, regs);
 
-	if (ret == 0) {
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
-		if (!(ka->sa.sa_flags & SA_NODEFER))
-			sigaddset(&current->blocked,sig);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
-	}
+	if (ret == 0)
+		block_sigmask(ka, sig);
 
 	return ret;
 }
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 31/43] sparc: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (29 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 30/43] sh: Use set_current_blocked() and block_sigmask() Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 32/43] tile: " Matt Fleming
                   ` (12 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, David S. Miller

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/sparc/kernel/signal32.c  |   17 +++--------------
 arch/sparc/kernel/signal_32.c |   28 +++++++++-------------------
 arch/sparc/kernel/signal_64.c |   29 ++++++++++-------------------
 3 files changed, 22 insertions(+), 52 deletions(-)

diff --git a/arch/sparc/kernel/signal32.c b/arch/sparc/kernel/signal32.c
index 75fad42..88a3841 100644
--- a/arch/sparc/kernel/signal32.c
+++ b/arch/sparc/kernel/signal32.c
@@ -287,10 +287,7 @@ void do_sigreturn32(struct pt_regs *regs)
 		case 1: set.sig[0] = seta[0] + (((long)seta[1]) << 32);
 	}
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 	return;
 
 segv:
@@ -383,10 +380,7 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
 		case 1: set.sig[0] = seta.sig[0] + (((long)seta.sig[1]) << 32);
 	}
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 	return;
 segv:
 	force_sig(SIGSEGV, current);
@@ -766,12 +760,7 @@ static inline int handle_signal32(unsigned long signr, struct k_sigaction *ka,
 	if (err)
 		return err;
 
-	spin_lock_irq(&current->sighand->siglock);
-	sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NOMASK))
-		sigaddset(&current->blocked,signr);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	block_sigmask(ka, signr);
 
 	tracehook_signal_handler(signr, info, ka, regs, 0);
 
diff --git a/arch/sparc/kernel/signal_32.c b/arch/sparc/kernel/signal_32.c
index 5e5c5fd..f6b0fab 100644
--- a/arch/sparc/kernel/signal_32.c
+++ b/arch/sparc/kernel/signal_32.c
@@ -60,12 +60,13 @@ struct rt_signal_frame {
 
 static int _sigpause_common(old_sigset_t set)
 {
-	set &= _BLOCKABLE;
-	spin_lock_irq(&current->sighand->siglock);
+	sigset_t blocked;
+
 	current->saved_sigmask = current->blocked;
-	siginitset(&current->blocked, set);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+
+	set &= _BLOCKABLE;
+	siginitset(&blocked, set);
+	set_current_blocked(&blocked);
 
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
@@ -165,10 +166,7 @@ asmlinkage void do_sigreturn(struct pt_regs *regs)
 		goto segv_and_exit;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 	return;
 
 segv_and_exit:
@@ -229,10 +227,7 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
 	set_fs(old_fs);
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 	return;
 segv:
 	force_sig(SIGSEGV, current);
@@ -494,12 +489,7 @@ handle_signal(unsigned long signr, struct k_sigaction *ka,
 	if (err)
 		return err;
 
-	spin_lock_irq(&current->sighand->siglock);
-	sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NOMASK))
-		sigaddset(&current->blocked, signr);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	block_sigmask(ka, signr);
 
 	tracehook_signal_handler(signr, info, ka, regs, 0);
 
diff --git a/arch/sparc/kernel/signal_64.c b/arch/sparc/kernel/signal_64.c
index 006fe45..977e258 100644
--- a/arch/sparc/kernel/signal_64.c
+++ b/arch/sparc/kernel/signal_64.c
@@ -69,10 +69,7 @@ asmlinkage void sparc64_set_context(struct pt_regs *regs)
 				goto do_sigsegv;
 		}
 		sigdelsetmask(&set, ~_BLOCKABLE);
-		spin_lock_irq(&current->sighand->siglock);
-		current->blocked = set;
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
+		set_current_blocked(&set);
 	}
 	if (test_thread_flag(TIF_32BIT)) {
 		pc &= 0xffffffff;
@@ -241,12 +238,13 @@ struct rt_signal_frame {
 
 static long _sigpause_common(old_sigset_t set)
 {
-	set &= _BLOCKABLE;
-	spin_lock_irq(&current->sighand->siglock);
+	sigset_t blocked;
+
 	current->saved_sigmask = current->blocked;
-	siginitset(&current->blocked, set);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+
+	set &= _BLOCKABLE;
+	siginitset(&blocked, set);
+	set_current_blocked(&blocked);
 
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
@@ -341,10 +339,7 @@ void do_rt_sigreturn(struct pt_regs *regs)
 	pt_regs_clear_syscall(regs);
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 	return;
 segv:
 	force_sig(SIGSEGV, current);
@@ -504,12 +499,8 @@ static inline int handle_signal(unsigned long signr, struct k_sigaction *ka,
 			     (ka->sa.sa_flags & SA_SIGINFO) ? info : NULL);
 	if (err)
 		return err;
-	spin_lock_irq(&current->sighand->siglock);
-	sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NOMASK))
-		sigaddset(&current->blocked,signr);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+
+	block_sigmask(ka, signr);
 
 	tracehook_signal_handler(signr, info, ka, regs, 0);
 
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 32/43] tile: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (30 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 31/43] sparc: " Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-29 20:44   ` Chris Metcalf
  2011-08-19 16:46 ` [PATCH v2 33/43] um: " Matt Fleming
                   ` (11 subsequent siblings)
  43 siblings, 1 reply; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Arnd Bergmann, Chris Metcalf

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

Chris, I dropped your Acked-by because I felt this patch changed quite
dramatically since v1 and warrants another review. I hope that's OK.


 arch/tile/kernel/compat_signal.c |    5 +----
 arch/tile/kernel/signal.c        |   13 ++-----------
 2 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/arch/tile/kernel/compat_signal.c b/arch/tile/kernel/compat_signal.c
index a7869ad..77763cc 100644
--- a/arch/tile/kernel/compat_signal.c
+++ b/arch/tile/kernel/compat_signal.c
@@ -303,10 +303,7 @@ long compat_sys_rt_sigreturn(struct pt_regs *regs)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
 		goto badframe;
diff --git a/arch/tile/kernel/signal.c b/arch/tile/kernel/signal.c
index bedaf4e..f79d4b8 100644
--- a/arch/tile/kernel/signal.c
+++ b/arch/tile/kernel/signal.c
@@ -97,10 +97,7 @@ SYSCALL_DEFINE1(rt_sigreturn, struct pt_regs *, regs)
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
 		goto badframe;
@@ -286,13 +283,7 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
 		 * the work_pending path in the return-to-user code, and
 		 * either way we can re-enable interrupts unconditionally.
 		 */
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked,
-			  &current->blocked, &ka->sa.sa_mask);
-		if (!(ka->sa.sa_flags & SA_NODEFER))
-			sigaddset(&current->blocked, sig);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
+		block_sigmask(ka, sig);
 	}
 
 	return ret;
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 33/43] um: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (31 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 32/43] tile: " Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 34/43] um: Don't restore current->blocked on error Matt Fleming
                   ` (10 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Richard Weinberger

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Richard Weinberger <richard@nod.at>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

Richard, I dropped your Acked-by because I felt this patch changed
quite dramatically since v1 and warrants another review. I hope that's
OK.

 arch/um/kernel/signal.c     |   22 ++++++++--------------
 arch/um/sys-i386/signal.c   |   12 ++----------
 arch/um/sys-x86_64/signal.c |    6 +-----
 3 files changed, 11 insertions(+), 29 deletions(-)

diff --git a/arch/um/kernel/signal.c b/arch/um/kernel/signal.c
index b5c094c..9aa5cba 100644
--- a/arch/um/kernel/signal.c
+++ b/arch/um/kernel/signal.c
@@ -72,15 +72,8 @@ static int handle_signal(struct pt_regs *regs, unsigned long signr,
 		recalc_sigpending();
 		spin_unlock_irq(&current->sighand->siglock);
 		force_sigsegv(signr, current);
-	} else {
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked, &current->blocked,
-			  &ka->sa.sa_mask);
-		if (!(ka->sa.sa_flags & SA_NODEFER))
-			sigaddset(&current->blocked, signr);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
-	}
+	} else
+		block_sigmask(ka, signr);
 
 	return err;
 }
@@ -163,12 +156,13 @@ int do_signal(void)
  */
 long sys_sigsuspend(int history0, int history1, old_sigset_t mask)
 {
-	mask &= _BLOCKABLE;
-	spin_lock_irq(&current->sighand->siglock);
+	sigset_t blocked;
+
 	current->saved_sigmask = current->blocked;
-	siginitset(&current->blocked, mask);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+
+	mask &= _BLOCKABLE;
+	siginitset(&blocked, mask);
+	set_current_blocked(&blocked);
 
 	current->state = TASK_INTERRUPTIBLE;
 	schedule();
diff --git a/arch/um/sys-i386/signal.c b/arch/um/sys-i386/signal.c
index 89a4662..4403b48 100644
--- a/arch/um/sys-i386/signal.c
+++ b/arch/um/sys-i386/signal.c
@@ -458,11 +458,7 @@ long sys_sigreturn(struct pt_regs regs)
 		goto segfault;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (copy_sc_from_user(&current->thread.regs, sc))
 		goto segfault;
@@ -489,11 +485,7 @@ long sys_rt_sigreturn(struct pt_regs regs)
 		goto segfault;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (copy_sc_from_user(&current->thread.regs, &uc->uc_mcontext))
 		goto segfault;
diff --git a/arch/um/sys-x86_64/signal.c b/arch/um/sys-x86_64/signal.c
index b6b65c7..581b64d 100644
--- a/arch/um/sys-x86_64/signal.c
+++ b/arch/um/sys-x86_64/signal.c
@@ -270,11 +270,7 @@ long sys_rt_sigreturn(struct pt_regs *regs)
 		goto segfault;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (copy_sc_from_user(&current->thread.regs, &uc->uc_mcontext,
 			      &frame->fpstate))
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 34/43] um: Don't restore current->blocked on error
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (32 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 33/43] um: " Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 35/43] unicore32: Use set_current_blocked() and block_sigmask() Matt Fleming
                   ` (9 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel

From: Matt Fleming <matt.fleming@intel.com>

If we fail to setup the signal stack frame then we don't need to
restore current->blocked because it is not modified by
setup_signal_stack_*.

Acked-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Richard Weinberger <richard@nod.at>
Tested-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 arch/um/kernel/signal.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/um/kernel/signal.c b/arch/um/kernel/signal.c
index 9aa5cba..9a5ffe1 100644
--- a/arch/um/kernel/signal.c
+++ b/arch/um/kernel/signal.c
@@ -66,13 +66,9 @@ static int handle_signal(struct pt_regs *regs, unsigned long signr,
 #endif
 		err = setup_signal_stack_si(sp, signr, ka, regs, info, oldset);
 
-	if (err) {
-		spin_lock_irq(&current->sighand->siglock);
-		current->blocked = *oldset;
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
+	if (err)
 		force_sigsegv(signr, current);
-	} else
+	else
 		block_sigmask(ka, signr);
 
 	return err;
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 35/43] unicore32: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (33 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 34/43] um: Don't restore current->blocked on error Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-22  2:15   ` Guan Xuetao
  2011-08-19 16:46 ` [PATCH v2 36/43] xtensa: Don't reimplement force_sigsegv() Matt Fleming
                   ` (8 subsequent siblings)
  43 siblings, 1 reply; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Guan Xuetao

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

Guan, I dropped your Acked-by because I felt this patch changed quite
dramatically since v1 and warrants another review. I hope that's OK.

 arch/unicore32/kernel/signal.c |   13 ++-----------
 1 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/arch/unicore32/kernel/signal.c b/arch/unicore32/kernel/signal.c
index b163fca..960c029 100644
--- a/arch/unicore32/kernel/signal.c
+++ b/arch/unicore32/kernel/signal.c
@@ -63,10 +63,7 @@ static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
 	err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set));
 	if (err == 0) {
 		sigdelsetmask(&set, ~_BLOCKABLE);
-		spin_lock_irq(&current->sighand->siglock);
-		current->blocked = set;
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
+		set_current_blocked(&set);
 	}
 
 	err |= __get_user(regs->UCreg_00, &sf->uc.uc_mcontext.regs.UCreg_00);
@@ -372,13 +369,7 @@ static int handle_signal(unsigned long sig, struct k_sigaction *ka,
 	/*
 	 * Block the signal if we were successful.
 	 */
-	spin_lock_irq(&tsk->sighand->siglock);
-	sigorsets(&tsk->blocked, &tsk->blocked,
-		  &ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&tsk->blocked, sig);
-	recalc_sigpending();
-	spin_unlock_irq(&tsk->sighand->siglock);
+	block_sigmask(ka, sig);
 
 	return 0;
 }
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 36/43] xtensa: Don't reimplement force_sigsegv()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (34 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 35/43] unicore32: Use set_current_blocked() and block_sigmask() Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 37/43] xtensa: No need to reset handler if SA_ONESHOT Matt Fleming
                   ` (7 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Chris Zankel

From: Matt Fleming <matt.fleming@intel.com>

Instead of open coding the sequence from force_sigsegv() just call
it. This also fixes a bug because we were modifying ka->sa.sa_handler
(which is a copy of sighand->action[]), whereas the intention of the
code was to modify sighand->action[] directly.

As the original code was working with a copy it had no effect on
signal delivery.

Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Chris Zankel <chris@zankel.net>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 arch/xtensa/kernel/signal.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/arch/xtensa/kernel/signal.c b/arch/xtensa/kernel/signal.c
index f2220b5..4f53770 100644
--- a/arch/xtensa/kernel/signal.c
+++ b/arch/xtensa/kernel/signal.c
@@ -425,9 +425,7 @@ static void setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
 	return;
 
 give_sigsegv:
-	if (sig == SIGSEGV)
-		ka->sa.sa_handler = SIG_DFL;
-	force_sig(SIGSEGV, current);
+	force_sigsegv(sig, current);
 }
 
 /*
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 37/43] xtensa: No need to reset handler if SA_ONESHOT
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (35 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 36/43] xtensa: Don't reimplement force_sigsegv() Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 38/43] xtensa: Don't mask signals if we fail to setup signal stack Matt Fleming
                   ` (6 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Chris Zankel

From: Matt Fleming <matt.fleming@intel.com>

get_signal_to_deliver() already resets the signal handler if
SA_ONESHOT is set in ka->sa.sa_flags, there's no need to do it again
in handle_signal(). Furthermore, because we were modifying
ka->sa.sa_handler (which is a copy of sighand->action[]) instead of
sighand->action[] the original code actually had no effect on signal
delivery.

Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Chris Zankel <chris@zankel.net>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 arch/xtensa/kernel/signal.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/arch/xtensa/kernel/signal.c b/arch/xtensa/kernel/signal.c
index 4f53770..24655e3 100644
--- a/arch/xtensa/kernel/signal.c
+++ b/arch/xtensa/kernel/signal.c
@@ -536,9 +536,6 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
 		/* Set up the stack frame */
 		setup_frame(signr, &ka, &info, oldset, regs);
 
-		if (ka.sa.sa_flags & SA_ONESHOT)
-			ka.sa.sa_handler = SIG_DFL;
-
 		spin_lock_irq(&current->sighand->siglock);
 		sigorsets(&current->blocked, &current->blocked, &ka.sa.sa_mask);
 		if (!(ka.sa.sa_flags & SA_NODEFER))
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 38/43] xtensa: Don't mask signals if we fail to setup signal stack
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (36 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 37/43] xtensa: No need to reset handler if SA_ONESHOT Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 39/43] xtensa: Use set_current_blocked() and block_sigmask() Matt Fleming
                   ` (5 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Chris Zankel

From: Matt Fleming <matt.fleming@intel.com>

setup_frame() needs to return an indication of whether it succeeded or
failed in setting up the signal stack frame. If setup_frame() fails
then we must not modify current->blocked.

Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Chris Zankel <chris@zankel.net>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 arch/xtensa/kernel/signal.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/xtensa/kernel/signal.c b/arch/xtensa/kernel/signal.c
index 24655e3..17ceab8 100644
--- a/arch/xtensa/kernel/signal.c
+++ b/arch/xtensa/kernel/signal.c
@@ -336,8 +336,8 @@ gen_return_code(unsigned char *codemem)
 }
 
 
-static void setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
-			sigset_t *set, struct pt_regs *regs)
+static int setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
+		       sigset_t *set, struct pt_regs *regs)
 {
 	struct rt_sigframe *frame;
 	int err = 0;
@@ -422,10 +422,11 @@ static void setup_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
 		current->comm, current->pid, signal, frame, regs->pc);
 #endif
 
-	return;
+	return 0;
 
 give_sigsegv:
 	force_sigsegv(sig, current);
+	return -EFAULT;
 }
 
 /*
@@ -534,7 +535,9 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
 
 		/* Whee!  Actually deliver the signal.  */
 		/* Set up the stack frame */
-		setup_frame(signr, &ka, &info, oldset, regs);
+		ret = setup_frame(signr, &ka, &info, oldset, regs);
+		if (ret)
+			return ret;
 
 		spin_lock_irq(&current->sighand->siglock);
 		sigorsets(&current->blocked, &current->blocked, &ka.sa.sa_mask);
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 39/43] xtensa: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (37 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 38/43] xtensa: Don't mask signals if we fail to setup signal stack Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 40/43] autofs4: Use set_current_blocked() Matt Fleming
                   ` (4 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Chris Zankel

From: Matt Fleming <matt.fleming@intel.com>

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 block_sigmask() 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.

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Chris Zankel <chris@zankel.net>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---

v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
for adding sigmask to current->blocked" so they need to go through the
same tree but this patch would benefit from some maintainer ACK's.

 arch/xtensa/kernel/signal.c |   17 +++--------------
 1 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/arch/xtensa/kernel/signal.c b/arch/xtensa/kernel/signal.c
index 17ceab8..b69b000 100644
--- a/arch/xtensa/kernel/signal.c
+++ b/arch/xtensa/kernel/signal.c
@@ -260,10 +260,7 @@ asmlinkage long xtensa_rt_sigreturn(long a0, long a1, long a2, long a3,
 		goto badframe;
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = set;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);
 
 	if (restore_sigcontext(regs, frame))
 		goto badframe;
@@ -448,11 +445,8 @@ asmlinkage long xtensa_rt_sigsuspend(sigset_t __user *unewset,
 		return -EFAULT;
 
 	sigdelsetmask(&newset, ~_BLOCKABLE);
-	spin_lock_irq(&current->sighand->siglock);
 	saveset = current->blocked;
-	current->blocked = newset;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&newset);
 
 	regs->areg[2] = -EINTR;
 	while (1) {
@@ -539,12 +533,7 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
 		if (ret)
 			return ret;
 
-		spin_lock_irq(&current->sighand->siglock);
-		sigorsets(&current->blocked, &current->blocked, &ka.sa.sa_mask);
-		if (!(ka.sa.sa_flags & SA_NODEFER))
-			sigaddset(&current->blocked, signr);
-		recalc_sigpending();
-		spin_unlock_irq(&current->sighand->siglock);
+		block_sigmask(&ka, signr);
 		if (current->ptrace & PT_SINGLESTEP)
 			task_pt_regs(current)->icountlevel = 1;
 
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 40/43] autofs4: Use set_current_blocked()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (38 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 39/43] xtensa: Use set_current_blocked() and block_sigmask() Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 41/43] coda: " Matt Fleming
                   ` (3 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Ian Kent

From: Matt Fleming <matt.fleming@intel.com>

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.

Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Ian Kent <raven@themaw.net>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 fs/autofs4/waitq.c |   13 ++++---------
 1 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index e1fbdee..58ba49a 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -458,21 +458,16 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
 	 */
 	if (wq->name.name) {
 		/* Block all but "shutdown" signals while waiting */
-		sigset_t oldset;
+		sigset_t oldset, blocked;
 		unsigned long irqflags;
 
-		spin_lock_irqsave(&current->sighand->siglock, irqflags);
 		oldset = current->blocked;
-		siginitsetinv(&current->blocked, SHUTDOWN_SIGS & ~oldset.sig[0]);
-		recalc_sigpending();
-		spin_unlock_irqrestore(&current->sighand->siglock, irqflags);
+		siginitsetinv(&blocked, SHUTDOWN_SIGS & ~oldset.sig[0]);
+		set_current_blocked(&blocked);
 
 		wait_event_interruptible(wq->queue, wq->name.name == NULL);
 
-		spin_lock_irqsave(&current->sighand->siglock, irqflags);
-		current->blocked = oldset;
-		recalc_sigpending();
-		spin_unlock_irqrestore(&current->sighand->siglock, irqflags);
+		set_current_blocked(&oldset);
 	} else {
 		DPRINTK("skipped sleeping");
 	}
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 41/43] coda: Use set_current_blocked()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (39 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 40/43] autofs4: Use set_current_blocked() Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 42/43] dlm: Remove another superfluous call to recalc_sigpending() Matt Fleming
                   ` (2 subsequent siblings)
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Jan Harkes

From: Matt Fleming <matt.fleming@intel.com>

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.

Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Jan Harkes <jaharkes@cs.cmu.edu>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 fs/coda/upcall.c |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
index 9727e0c..ce5925d 100644
--- a/fs/coda/upcall.c
+++ b/fs/coda/upcall.c
@@ -575,24 +575,21 @@ int venus_statfs(struct dentry *dentry, struct kstatfs *sfs)
  */
 static void coda_block_signals(sigset_t *old)
 {
-	spin_lock_irq(&current->sighand->siglock);
+	sigset_t blocked;
+
 	*old = current->blocked;
 
-	sigfillset(&current->blocked);
-	sigdelset(&current->blocked, SIGKILL);
-	sigdelset(&current->blocked, SIGSTOP);
-	sigdelset(&current->blocked, SIGINT);
+	sigfillset(&blocked);
+	sigdelset(&blocked, SIGKILL);
+	sigdelset(&blocked, SIGSTOP);
+	sigdelset(&blocked, SIGINT);
 
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&blocked);
 }
 
 static void coda_unblock_signals(sigset_t *old)
 {
-	spin_lock_irq(&current->sighand->siglock);
-	current->blocked = *old;
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(old);
 }
 
 /* Don't allow signals to interrupt the following upcalls before venus
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 42/43] dlm: Remove another superfluous call to recalc_sigpending()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (40 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 41/43] coda: " Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-19 16:46 ` [PATCH v2 43/43] ncpfs: Use set_current_blocked() Matt Fleming
  2011-08-24 18:24 ` [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Oleg Nesterov
  43 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Christine Caulfield

From: Matt Fleming <matt.fleming@intel.com>

recalc_sigpending() is called within sigprocmask(), so there is no
need call it again after sigprocmask() has returned. Furthermore, the
call to recalc_sigpending() could race with signal_wake_up() because
it isn't called with sighand->siglock held. I must have missed this
call when removing the other recalc_sigpending() in commit
4bcad6c1ef53 ("dlm: Remove superfluous call to recalc_sigpending())".

Cc: Christine Caulfield <ccaulfie@redhat.com>
Acked-by: David Teigland <teigland@redhat.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 fs/dlm/user.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index d8ea607..b38b122 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -678,7 +678,6 @@ static int device_close(struct inode *inode, struct file *file)
 	   device_remove_lockspace() */
 
 	sigprocmask(SIG_SETMASK, &tmpsig, NULL);
-	recalc_sigpending();
 
 	return 0;
 }
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* [PATCH v2 43/43] ncpfs: Use set_current_blocked()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (41 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 42/43] dlm: Remove another superfluous call to recalc_sigpending() Matt Fleming
@ 2011-08-19 16:46 ` Matt Fleming
  2011-08-24 17:36   ` Oleg Nesterov
  2011-08-24 18:24 ` [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Oleg Nesterov
  43 siblings, 1 reply; 71+ messages in thread
From: Matt Fleming @ 2011-08-19 16:46 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Petr Vandrovec, Al Viro, Arnd Bergmann

From: Matt Fleming <matt.fleming@intel.com>

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, there's no need to hold sighand->siglock while reading
sighand->action[] because the lock is dropped across the call to
do_ncp_rpc_call() during which time another thread could modify
->action[].

Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Petr Vandrovec <petr@vandrovec.name>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
---
 fs/ncpfs/sock.c |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/fs/ncpfs/sock.c b/fs/ncpfs/sock.c
index 3a15872..850768a 100644
--- a/fs/ncpfs/sock.c
+++ b/fs/ncpfs/sock.c
@@ -749,10 +749,9 @@ static int ncp_do_request(struct ncp_server *server, int size,
 		return -EIO;
 	}
 	{
-		sigset_t old_set;
-		unsigned long mask, flags;
+		sigset_t old_set, blocked;
+		unsigned long mask;
 
-		spin_lock_irqsave(&current->sighand->siglock, flags);
 		old_set = current->blocked;
 		if (current->flags & PF_EXITING)
 			mask = 0;
@@ -769,16 +768,12 @@ static int ncp_do_request(struct ncp_server *server, int size,
 			if (current->sighand->action[SIGQUIT - 1].sa.sa_handler == SIG_DFL)
 				mask |= sigmask(SIGQUIT);
 		}
-		siginitsetinv(&current->blocked, mask);
-		recalc_sigpending();
-		spin_unlock_irqrestore(&current->sighand->siglock, flags);
+		siginitsetinv(&blocked, mask);
+		set_current_blocked(&blocked);
 		
 		result = do_ncp_rpc_call(server, size, reply, max_reply_size);
 
-		spin_lock_irqsave(&current->sighand->siglock, flags);
-		current->blocked = old_set;
-		recalc_sigpending();
-		spin_unlock_irqrestore(&current->sighand->siglock, flags);
+		set_current_blocked(&old_set);
 	}
 
 	DDPRINTK("do_ncp_rpc_call returned %d\n", result);
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 18/43] MIPS: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 ` [PATCH v2 18/43] MIPS: " Matt Fleming
@ 2011-08-19 17:27   ` Ralf Baechle
  0 siblings, 0 replies; 71+ messages in thread
From: Ralf Baechle @ 2011-08-19 17:27 UTC (permalink / raw)
  To: Matt Fleming; +Cc: Oleg Nesterov, linux-kernel, Al Viro, David Daney

On Fri, Aug 19, 2011 at 05:46:34PM +0100, Matt Fleming wrote:

Looks reasonable.

Acked-by: Ralf Baechle <ralf@linux-mips.org>

  Ralf

^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 07/43] blackfin: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 ` [PATCH v2 07/43] blackfin: Use set_current_blocked() and block_sigmask() Matt Fleming
@ 2011-08-20  4:00   ` Mike Frysinger
  2011-08-20  8:36     ` Matt Fleming
  0 siblings, 1 reply; 71+ messages in thread
From: Mike Frysinger @ 2011-08-20  4:00 UTC (permalink / raw)
  To: Matt Fleming; +Cc: Oleg Nesterov, linux-kernel

On Fri, Aug 19, 2011 at 12:46, Matt Fleming wrote:
> --- a/arch/blackfin/kernel/signal.c
> +++ b/arch/blackfin/kernel/signal.c
> -       if (ret == 0) {
> -               spin_lock_irq(&current->sighand->siglock);
> -               sigorsets(&current->blocked, &current->blocked,
> -                         &ka->sa.sa_mask);
> -               if (!(ka->sa.sa_flags & SA_NODEFER))
> -                       sigaddset(&current->blocked, sig);
> -               recalc_sigpending();
> -               spin_unlock_irq(&current->sighand->siglock);
> -       }
> +       if (ret == 0)
> +               block_sigmask(ka, sig);

the Blackfin version holds siglock and calls recalc_sigpending() while
block_sigmask() does neither.  i'm guessing that is expected behavior
now ?
-mike

^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 07/43] blackfin: Use set_current_blocked() and block_sigmask()
  2011-08-20  4:00   ` Mike Frysinger
@ 2011-08-20  8:36     ` Matt Fleming
  2011-08-20 17:31       ` Mike Frysinger
  0 siblings, 1 reply; 71+ messages in thread
From: Matt Fleming @ 2011-08-20  8:36 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: Oleg Nesterov, linux-kernel

On Sat, 2011-08-20 at 00:00 -0400, Mike Frysinger wrote:
> On Fri, Aug 19, 2011 at 12:46, Matt Fleming wrote:
> > --- a/arch/blackfin/kernel/signal.c
> > +++ b/arch/blackfin/kernel/signal.c
> > -       if (ret == 0) {
> > -               spin_lock_irq(&current->sighand->siglock);
> > -               sigorsets(&current->blocked, &current->blocked,
> > -                         &ka->sa.sa_mask);
> > -               if (!(ka->sa.sa_flags & SA_NODEFER))
> > -                       sigaddset(&current->blocked, sig);
> > -               recalc_sigpending();
> > -               spin_unlock_irq(&current->sighand->siglock);
> > -       }
> > +       if (ret == 0)
> > +               block_sigmask(ka, sig);
> 
> the Blackfin version holds siglock and calls recalc_sigpending() while
> block_sigmask() does neither.  i'm guessing that is expected behavior
> now ?

Yah, set_current_blocked() inside of block_sigmask() still grabs siglock
and calls recalc_sigpending() for you. Reading current->blocked inside
of block_sigmask() is fine and the sigorsets() is OK because we're
modifying a stack variable, so only grabbing the lock inside of
set_current_blocked() is safe.

-- 
Matt Fleming, Intel Open Source Technology Center


^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 07/43] blackfin: Use set_current_blocked() and block_sigmask()
  2011-08-20  8:36     ` Matt Fleming
@ 2011-08-20 17:31       ` Mike Frysinger
  0 siblings, 0 replies; 71+ messages in thread
From: Mike Frysinger @ 2011-08-20 17:31 UTC (permalink / raw)
  To: Matt Fleming; +Cc: Oleg Nesterov, linux-kernel

On Sat, Aug 20, 2011 at 04:36, Matt Fleming wrote:
> On Sat, 2011-08-20 at 00:00 -0400, Mike Frysinger wrote:
>> On Fri, Aug 19, 2011 at 12:46, Matt Fleming wrote:
>> > --- a/arch/blackfin/kernel/signal.c
>> > +++ b/arch/blackfin/kernel/signal.c
>> > -       if (ret == 0) {
>> > -               spin_lock_irq(&current->sighand->siglock);
>> > -               sigorsets(&current->blocked, &current->blocked,
>> > -                         &ka->sa.sa_mask);
>> > -               if (!(ka->sa.sa_flags & SA_NODEFER))
>> > -                       sigaddset(&current->blocked, sig);
>> > -               recalc_sigpending();
>> > -               spin_unlock_irq(&current->sighand->siglock);
>> > -       }
>> > +       if (ret == 0)
>> > +               block_sigmask(ka, sig);
>>
>> the Blackfin version holds siglock and calls recalc_sigpending() while
>> block_sigmask() does neither.  i'm guessing that is expected behavior
>> now ?
>
> Yah, set_current_blocked() inside of block_sigmask() still grabs siglock
> and calls recalc_sigpending() for you. Reading current->blocked inside
> of block_sigmask() is fine and the sigorsets() is OK because we're
> modifying a stack variable, so only grabbing the lock inside of
> set_current_blocked() is safe.

thanks for clearing that up (and the code itself!).

Acked-by: Mike Frysinger <vapier@gentoo.org>
-mike

^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 35/43] unicore32: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 ` [PATCH v2 35/43] unicore32: Use set_current_blocked() and block_sigmask() Matt Fleming
@ 2011-08-22  2:15   ` Guan Xuetao
  2011-08-22 10:26     ` Matt Fleming
  0 siblings, 1 reply; 71+ messages in thread
From: Guan Xuetao @ 2011-08-22  2:15 UTC (permalink / raw)
  To: Matt Fleming; +Cc: Oleg Nesterov, linux-kernel, Arnd Bergmann

Hi, Matt
Could you add me (and other relevant people) to the patch series, or at
least the main patches in the series, since the separated patch is hard
to understand, and can't be tested.

For signal patches, I can only test it by booting up the system, running
some commands, and perhaps, running lmbench or ltp.
Is there any testsuite specified to signal part?


Cc: Arnd Bergmann <arnd@arndb.de>

Thanks Matt.
Guan Xuetao

On Fri, 2011-08-19 at 17:46 +0100, Matt Fleming wrote:
> From: Matt Fleming <matt.fleming@intel.com>
> 
> 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 block_sigmask() 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.
> 
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
> ---
> 
> v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
> for adding sigmask to current->blocked" so they need to go through the
> same tree but this patch would benefit from some maintainer ACK's.
> 
> Guan, I dropped your Acked-by because I felt this patch changed quite
> dramatically since v1 and warrants another review. I hope that's OK.
> 
>  arch/unicore32/kernel/signal.c |   13 ++-----------
>  1 files changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/unicore32/kernel/signal.c b/arch/unicore32/kernel/signal.c
> index b163fca..960c029 100644
> --- a/arch/unicore32/kernel/signal.c
> +++ b/arch/unicore32/kernel/signal.c
> @@ -63,10 +63,7 @@ static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
>  	err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set));
>  	if (err == 0) {
>  		sigdelsetmask(&set, ~_BLOCKABLE);
> -		spin_lock_irq(&current->sighand->siglock);
> -		current->blocked = set;
> -		recalc_sigpending();
> -		spin_unlock_irq(&current->sighand->siglock);
> +		set_current_blocked(&set);
>  	}
>  
>  	err |= __get_user(regs->UCreg_00, &sf->uc.uc_mcontext.regs.UCreg_00);
> @@ -372,13 +369,7 @@ static int handle_signal(unsigned long sig, struct k_sigaction *ka,
>  	/*
>  	 * Block the signal if we were successful.
>  	 */
> -	spin_lock_irq(&tsk->sighand->siglock);
> -	sigorsets(&tsk->blocked, &tsk->blocked,
> -		  &ka->sa.sa_mask);
> -	if (!(ka->sa.sa_flags & SA_NODEFER))
> -		sigaddset(&tsk->blocked, sig);
> -	recalc_sigpending();
> -	spin_unlock_irq(&tsk->sighand->siglock);
> +	block_sigmask(ka, sig);
>  
>  	return 0;
>  }



^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH 01/43] signal: Add block_sigmask() for adding sigmask to current->blocked
  2011-08-19 16:46 ` [PATCH 01/43] signal: Add block_sigmask() for adding sigmask to current->blocked Matt Fleming
@ 2011-08-22 10:19   ` Matt Fleming
  2011-08-22 14:01     ` Oleg Nesterov
  0 siblings, 1 reply; 71+ messages in thread
From: Matt Fleming @ 2011-08-22 10:19 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: linux-kernel, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	Tejun Heo, Andrew Morton, Guan Xuetao, linux-arch

(Adding linux-arch to Cc so arch maintainers will hopefully see this)

On Fri, 2011-08-19 at 17:46 +0100, Matt Fleming wrote:
> From: Matt Fleming <matt.fleming@intel.com>
> 
> 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.
> 
> Cc: 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: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
> ---
>  arch/x86/kernel/signal.c |    6 +-----
>  include/linux/signal.h   |    1 +
>  kernel/signal.c          |   21 +++++++++++++++++++++
>  3 files changed, 23 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
> index 54ddaeb2..46a01bd 100644
> --- a/arch/x86/kernel/signal.c
> +++ b/arch/x86/kernel/signal.c
> @@ -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, &current->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));
> diff --git a/include/linux/signal.h b/include/linux/signal.h
> index a822300..7987ce74 100644
> --- a/include/linux/signal.h
> +++ b/include/linux/signal.h
> @@ -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;
> diff --git a/kernel/signal.c b/kernel/signal.c
> index 291c970..7a08164 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -2314,6 +2314,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, &current->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




^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 35/43] unicore32: Use set_current_blocked() and block_sigmask()
  2011-08-22  2:15   ` Guan Xuetao
@ 2011-08-22 10:26     ` Matt Fleming
  2011-08-24  2:03       ` Guan Xuetao
  0 siblings, 1 reply; 71+ messages in thread
From: Matt Fleming @ 2011-08-22 10:26 UTC (permalink / raw)
  To: gxt; +Cc: Oleg Nesterov, linux-kernel, Arnd Bergmann

On Mon, 2011-08-22 at 10:15 +0800, Guan Xuetao wrote:
> Hi, Matt
> Could you add me (and other relevant people) to the patch series, or at
> least the main patches in the series, since the separated patch is hard
> to understand, and can't be tested.
> 
> For signal patches, I can only test it by booting up the system, running
> some commands, and perhaps, running lmbench or ltp.
> Is there any testsuite specified to signal part?
> 
> 
> Cc: Arnd Bergmann <arnd@arndb.de>
> 
> Thanks Matt.
> Guan Xuetao

Hi Guan,

Unfortunately there are too many maintainers to add directly to the Cc
list. However, I did reply to the first patch in the series (the only
other one that matters for arch maintainers) and added yourself and
linux-arch, so hopefully the rest of the arch maintainers will find it
there. But just to be complete, the link to the patch is here,

	https://lkml.org/lkml/2011/8/19/409

There isn't really a specific testsuite that I would recommend, though
I'm pretty sure that LTP has some signal-related test cases. Booting up
your system and running some commands (and perhaps interrupting them
with Ctrl-C) should be good enough.

-- 
Matt Fleming, Intel Open Source Technology Center


^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH 01/43] signal: Add block_sigmask() for adding sigmask to current->blocked
  2011-08-22 10:19   ` Matt Fleming
@ 2011-08-22 14:01     ` Oleg Nesterov
  2011-08-22 14:04       ` Oleg Nesterov
  2011-08-22 15:56       ` Matt Fleming
  0 siblings, 2 replies; 71+ messages in thread
From: Oleg Nesterov @ 2011-08-22 14:01 UTC (permalink / raw)
  To: Matt Fleming
  Cc: linux-kernel, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	Tejun Heo, Andrew Morton, Guan Xuetao, linux-arch

On 08/22, Matt Fleming wrote:
>
> (Adding linux-arch to Cc so arch maintainers will hopefully see this)

Yes, thanks.

So far I applied only this patch to

	git://git.kernel.org/pub/scm/linux/kernel/git/oleg/misc.git ptrace

But I am going to take the whole series unless I have the nack from
maintainers. Everything looks correct.

IOW, I am going to wait a bit to collect the ACKs from the maintainers
in case (I hope ;) they want to review these changes.

OK?

Oleg.

> On Fri, 2011-08-19 at 17:46 +0100, Matt Fleming wrote:
> > From: Matt Fleming <matt.fleming@intel.com>
> > 
> > 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.
> > 
> > Cc: 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: Andrew Morton <akpm@linux-foundation.org>
> > Signed-off-by: Matt Fleming <matt.fleming@intel.com>
> > ---
> >  arch/x86/kernel/signal.c |    6 +-----
> >  include/linux/signal.h   |    1 +
> >  kernel/signal.c          |   21 +++++++++++++++++++++
> >  3 files changed, 23 insertions(+), 5 deletions(-)
> > 
> > diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
> > index 54ddaeb2..46a01bd 100644
> > --- a/arch/x86/kernel/signal.c
> > +++ b/arch/x86/kernel/signal.c
> > @@ -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, &current->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));
> > diff --git a/include/linux/signal.h b/include/linux/signal.h
> > index a822300..7987ce74 100644
> > --- a/include/linux/signal.h
> > +++ b/include/linux/signal.h
> > @@ -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;
> > diff --git a/kernel/signal.c b/kernel/signal.c
> > index 291c970..7a08164 100644
> > --- a/kernel/signal.c
> > +++ b/kernel/signal.c
> > @@ -2314,6 +2314,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, &current->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
> 
> 
> 


^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH 01/43] signal: Add block_sigmask() for adding sigmask to current->blocked
  2011-08-22 14:01     ` Oleg Nesterov
@ 2011-08-22 14:04       ` Oleg Nesterov
  2011-08-22 15:56       ` Matt Fleming
  1 sibling, 0 replies; 71+ messages in thread
From: Oleg Nesterov @ 2011-08-22 14:04 UTC (permalink / raw)
  To: Matt Fleming
  Cc: linux-kernel, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	Tejun Heo, Andrew Morton, Guan Xuetao, linux-arch

On 08/22, Oleg Nesterov wrote:
>
> On 08/22, Matt Fleming wrote:
> >
> > (Adding linux-arch to Cc so arch maintainers will hopefully see this)
>
> Yes, thanks.
>
> So far I applied only this patch to
>
> 	git://git.kernel.org/pub/scm/linux/kernel/git/oleg/misc.git ptrace
>
> But I am going to take the whole series unless I have the nack from
> maintainers. Everything looks correct.
>
> IOW, I am going to wait a bit to collect the ACKs from the maintainers
> in case (I hope ;) they want to review these changes.
>
> OK?

Forgot to mention... And of course, if someone wants to take a patch
please let me know.

Oleg.


^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH 01/43] signal: Add block_sigmask() for adding sigmask to current->blocked
  2011-08-22 14:01     ` Oleg Nesterov
  2011-08-22 14:04       ` Oleg Nesterov
@ 2011-08-22 15:56       ` Matt Fleming
  1 sibling, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-22 15:56 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: linux-kernel, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	Tejun Heo, Andrew Morton, Guan Xuetao, linux-arch

On Mon, 2011-08-22 at 16:01 +0200, Oleg Nesterov wrote:
> On 08/22, Matt Fleming wrote:
> >
> > (Adding linux-arch to Cc so arch maintainers will hopefully see this)
> 
> Yes, thanks.
> 
> So far I applied only this patch to
> 
> 	git://git.kernel.org/pub/scm/linux/kernel/git/oleg/misc.git ptrace
> 
> But I am going to take the whole series unless I have the nack from
> maintainers. Everything looks correct.
> 
> IOW, I am going to wait a bit to collect the ACKs from the maintainers
> in case (I hope ;) they want to review these changes.
> 
> OK?

That's fine with me!

-- 
Matt Fleming, Intel Open Source Technology Center


^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH 26/43] [S390]: Use block_sigmask()
  2011-08-19 16:46 ` [PATCH 26/43] [S390]: Use block_sigmask() Matt Fleming
@ 2011-08-23  6:04   ` Martin Schwidefsky
  0 siblings, 0 replies; 71+ messages in thread
From: Martin Schwidefsky @ 2011-08-23  6:04 UTC (permalink / raw)
  To: Matt Fleming; +Cc: Oleg Nesterov, linux-kernel, Heiko Carstens

On Fri, 19 Aug 2011 17:46:42 +0100
Matt Fleming <matt@console-pimps.org> wrote:

> From: Matt Fleming <matt.fleming@intel.com>
> 
> Use the new helper function block_sigmask() 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.
> 
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
> ---
> 
> This patch depends on "[PATCH 01/43] signal: Add block_sigmask() for
> adding sigmask to current->blocked" so they need to go through the
> same tree but this patch would benefit from some maintainer ACK's.
> 
>  arch/s390/kernel/compat_signal.c |    6 +-----
>  arch/s390/kernel/signal.c        |    6 +-----
>  2 files changed, 2 insertions(+), 10 deletions(-)

Identical code replacement and compiles fine.
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 35/43] unicore32: Use set_current_blocked() and block_sigmask()
  2011-08-22 10:26     ` Matt Fleming
@ 2011-08-24  2:03       ` Guan Xuetao
  0 siblings, 0 replies; 71+ messages in thread
From: Guan Xuetao @ 2011-08-24  2:03 UTC (permalink / raw)
  To: Matt Fleming; +Cc: Oleg Nesterov, linux-kernel, Arnd Bergmann

Thanks Matt,

For unicore32 bit,

Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn>


On Mon, 2011-08-22 at 11:26 +0100, Matt Fleming wrote:
> On Mon, 2011-08-22 at 10:15 +0800, Guan Xuetao wrote:
> > Hi, Matt
> > Could you add me (and other relevant people) to the patch series, or at
> > least the main patches in the series, since the separated patch is hard
> > to understand, and can't be tested.
> > 
> > For signal patches, I can only test it by booting up the system, running
> > some commands, and perhaps, running lmbench or ltp.
> > Is there any testsuite specified to signal part?
> > 
> > 
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > 
> > Thanks Matt.
> > Guan Xuetao
> 
> Hi Guan,
> 
> Unfortunately there are too many maintainers to add directly to the Cc
> list. However, I did reply to the first patch in the series (the only
> other one that matters for arch maintainers) and added yourself and
> linux-arch, so hopefully the rest of the arch maintainers will find it
> there. But just to be complete, the link to the patch is here,
> 
> 	https://lkml.org/lkml/2011/8/19/409
> 
> There isn't really a specific testsuite that I would recommend, though
> I'm pretty sure that LTP has some signal-related test cases. Booting up
> your system and running some commands (and perhaps interrupting them
> with Ctrl-C) should be good enough.
> 



^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 13/43] m68k: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 ` [PATCH v2 13/43] m68k: " Matt Fleming
@ 2011-08-24  4:38   ` Greg Ungerer
  0 siblings, 0 replies; 71+ messages in thread
From: Greg Ungerer @ 2011-08-24  4:38 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Oleg Nesterov, linux-kernel, Geert Uytterhoeven, Greg Ungerer

Hi Matt,

On 20/08/11 02:46, Matt Fleming wrote:
> From: Matt Fleming<matt.fleming@intel.com>
>
> 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 block_sigmask() 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.
>
> Cc: Oleg Nesterov<oleg@redhat.com>
> Cc: Geert Uytterhoeven<geert@linux-m68k.org>
> Cc: Greg Ungerer<gerg@uclinux.org>
> Signed-off-by: Matt Fleming<matt.fleming@intel.com>

I don't see any problems. Fine by me.

Acked-by: Greg Ungerer <gerg@uclinux.org>

Regards
Greg


> ---
>
> v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
> for adding sigmask to current->blocked" so they need to go through the
> same tree but this patch would benefit from some maintainer ACK's.
>
>   arch/m68k/kernel/signal_mm.c |   22 +++++++++-------------
>   arch/m68k/kernel/signal_no.c |   28 +++++++++-------------------
>   2 files changed, 18 insertions(+), 32 deletions(-)
>
> diff --git a/arch/m68k/kernel/signal_mm.c b/arch/m68k/kernel/signal_mm.c
> index a0afc23..74ba0cf 100644
> --- a/arch/m68k/kernel/signal_mm.c
> +++ b/arch/m68k/kernel/signal_mm.c
> @@ -97,12 +97,13 @@ int handle_kernel_fault(struct pt_regs *regs)
>   asmlinkage int
>   sys_sigsuspend(int unused0, int unused1, old_sigset_t mask)
>   {
> -	mask&= _BLOCKABLE;
> -	spin_lock_irq(&current->sighand->siglock);
> +	sigset_t blocked;
> +
>   	current->saved_sigmask = current->blocked;
> -	siginitset(&current->blocked, mask);
> -	recalc_sigpending();
> -	spin_unlock_irq(&current->sighand->siglock);
> +
> +	mask&= _BLOCKABLE;
> +	siginitset(&blocked, mask);
> +	set_current_blocked(&blocked);
>
>   	current->state = TASK_INTERRUPTIBLE;
>   	schedule();
> @@ -465,8 +466,7 @@ asmlinkage int do_sigreturn(unsigned long __unused)
>   		goto badframe;
>
>   	sigdelsetmask(&set, ~_BLOCKABLE);
> -	current->blocked = set;
> -	recalc_sigpending();
> +	set_current_blocked(&set);
>
>   	if (restore_sigcontext(regs,&frame->sc, frame + 1))
>   		goto badframe;
> @@ -491,8 +491,7 @@ asmlinkage int do_rt_sigreturn(unsigned long __unused)
>   		goto badframe;
>
>   	sigdelsetmask(&set, ~_BLOCKABLE);
> -	current->blocked = set;
> -	recalc_sigpending();
> +	set_current_blocked(&set);
>
>   	if (rt_restore_ucontext(regs, sw,&frame->uc))
>   		goto badframe;
> @@ -965,10 +964,7 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
>   	if (err)
>   		return;
>
> -	sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
> -	if (!(ka->sa.sa_flags&  SA_NODEFER))
> -		sigaddset(&current->blocked,sig);
> -	recalc_sigpending();
> +	block_sigmask(ka, sig);
>
>   	if (test_thread_flag(TIF_DELAYED_TRACE)) {
>   		regs->sr&= ~0x8000;
> diff --git a/arch/m68k/kernel/signal_no.c b/arch/m68k/kernel/signal_no.c
> index 36a81bb..33e8bf5 100644
> --- a/arch/m68k/kernel/signal_no.c
> +++ b/arch/m68k/kernel/signal_no.c
> @@ -60,12 +60,13 @@ void ret_from_user_rt_signal(void);
>   asmlinkage int
>   sys_sigsuspend(int unused0, int unused1, old_sigset_t mask)
>   {
> -	mask&= _BLOCKABLE;
> -	spin_lock_irq(&current->sighand->siglock);
> +	sigset_t blocked;
> +
>   	current->saved_sigmask = current->blocked;
> -	siginitset(&current->blocked, mask);
> -	recalc_sigpending();
> -	spin_unlock_irq(&current->sighand->siglock);
> +
> +	mask&= _BLOCKABLE;
> +	siginitset(&blocked, mask);
> +	set_current_blocked(&blocked);
>
>   	current->state = TASK_INTERRUPTIBLE;
>   	schedule();
> @@ -343,10 +344,7 @@ asmlinkage int do_sigreturn(unsigned long __unused)
>   		goto badframe;
>
>   	sigdelsetmask(&set, ~_BLOCKABLE);
> -	spin_lock_irq(&current->sighand->siglock);
> -	current->blocked = set;
> -	recalc_sigpending();
> -	spin_unlock_irq(&current->sighand->siglock);
> +	set_current_blocked(&set);
>   	
>   	if (restore_sigcontext(regs,&frame->sc, frame + 1,&d0))
>   		goto badframe;
> @@ -372,10 +370,7 @@ asmlinkage int do_rt_sigreturn(unsigned long __unused)
>   		goto badframe;
>
>   	sigdelsetmask(&set, ~_BLOCKABLE);
> -	spin_lock_irq(&current->sighand->siglock);
> -	current->blocked = set;
> -	recalc_sigpending();
> -	spin_unlock_irq(&current->sighand->siglock);
> +	set_current_blocked(&set);
>   	
>   	if (rt_restore_ucontext(regs, sw,&frame->uc,&d0))
>   		goto badframe;
> @@ -708,12 +703,7 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
>   	if (err)
>   		return;
>
> -	spin_lock_irq(&current->sighand->siglock);
> -	sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
> -	if (!(ka->sa.sa_flags&  SA_NODEFER))
> -		sigaddset(&current->blocked,sig);
> -	recalc_sigpending();
> -	spin_unlock_irq(&current->sighand->siglock);
> +	block_sigmask(ka, sig);
>
>   	clear_thread_flag(TIF_RESTORE_SIGMASK);
>   }


-- 
------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com

^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 17/43] microblaze: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 ` [PATCH v2 17/43] microblaze: Use set_current_blocked() and block_sigmask() Matt Fleming
@ 2011-08-24  8:49   ` Michal Simek
  2011-08-24 10:21     ` Matt Fleming
  0 siblings, 1 reply; 71+ messages in thread
From: Michal Simek @ 2011-08-24  8:49 UTC (permalink / raw)
  To: Matt Fleming; +Cc: Oleg Nesterov, linux-kernel

Matt Fleming wrote:
> From: Matt Fleming <matt.fleming@intel.com>
> 
> 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 block_sigmask() 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.
> 
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: Michal Simek <monstr@monstr.eu>
> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
> ---
> 
> v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
> for adding sigmask to current->blocked" so they need to go through the
> same tree but this patch would benefit from some maintainer ACK's.

Please add there my ACK to it too.

> 
> Michal, I dropped your Acked-by because I felt this patch changed
> quite dramatically since v1 and warrants another review. I hope that's
> OK.

That's fine. I have run LTP tests and results look good.
I will add patches 14-16/43 v2 to microblaze next branch keep them
for a while. I will propose them to Linus tree for v3.2.

Thanks,
Michal

-- 
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian

^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 17/43] microblaze: Use set_current_blocked() and block_sigmask()
  2011-08-24  8:49   ` Michal Simek
@ 2011-08-24 10:21     ` Matt Fleming
  2011-08-24 13:53       ` Oleg Nesterov
  0 siblings, 1 reply; 71+ messages in thread
From: Matt Fleming @ 2011-08-24 10:21 UTC (permalink / raw)
  To: monstr; +Cc: Oleg Nesterov, linux-kernel

On Wed, 2011-08-24 at 10:49 +0200, Michal Simek wrote:
> > v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
> > for adding sigmask to current->blocked" so they need to go through the
> > same tree but this patch would benefit from some maintainer ACK's.
> 
> Please add there my ACK to it too.

OK will do, thanks.

> > 
> > Michal, I dropped your Acked-by because I felt this patch changed
> > quite dramatically since v1 and warrants another review. I hope that's
> > OK.
> 
> That's fine. I have run LTP tests and results look good.

Excellent!

> I will add patches 14-16/43 v2 to microblaze next branch keep them
> for a while. I will propose them to Linus tree for v3.2.

Actually, I just realised this is where it gets a little complicated. If
you take those 3 patches and they're not in Oleg's tree, [PATCH 17/43]
doesn't apply cleanly. Fixing 17/43 up so it applies without patches
14-16 would result in something like this in handle_signal(),

	if (!(ka->sa.sa_flags & SA_NODEFER)) {
		block_sigmask(ka, sig);
	}
	return 1;

Which Linus would have to fixup to its original form when he merges the
two trees. I think all the microblaze patches should go through Oleg's
tree, but it's really up to you two and Linus.

Oleg, if Michal does take patches 14-16 I can send you an updated patch
to apply.

-- 
Matt Fleming, Intel Open Source Technology Center


^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 17/43] microblaze: Use set_current_blocked() and block_sigmask()
  2011-08-24 10:21     ` Matt Fleming
@ 2011-08-24 13:53       ` Oleg Nesterov
  2011-08-24 14:02         ` Michal Simek
  0 siblings, 1 reply; 71+ messages in thread
From: Oleg Nesterov @ 2011-08-24 13:53 UTC (permalink / raw)
  To: Matt Fleming; +Cc: monstr, linux-kernel

On 08/24, Matt Fleming wrote:
>
> On Wed, 2011-08-24 at 10:49 +0200, Michal Simek wrote:
> > > v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
> > > for adding sigmask to current->blocked" so they need to go through the
> > > same tree but this patch would benefit from some maintainer ACK's.
> >
> > Please add there my ACK to it too.

Thanks Michal.

> > I will add patches 14-16/43 v2 to microblaze next branch keep them
> > for a while. I will propose them to Linus tree for v3.2.
>
> Actually, I just realised this is where it gets a little complicated. If
> you take those 3 patches and they're not in Oleg's tree, [PATCH 17/43]
> doesn't apply cleanly. Fixing 17/43 up so it applies without patches
> 14-16 would result in something like this in handle_signal(),
>
> 	if (!(ka->sa.sa_flags & SA_NODEFER)) {
> 		block_sigmask(ka, sig);
> 	}
> 	return 1;
>
> Which Linus would have to fixup to its original form when he merges the
> two trees. I think all the microblaze patches should go through Oleg's
> tree,

Agreed, this looks simpler.

Michal, unless you object, I am going to add the microblaze changes
(with your acks) to ptrace branch, it already has 01/43 which adds
block_sigmask().

OK?

Oleg.


^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 17/43] microblaze: Use set_current_blocked() and block_sigmask()
  2011-08-24 13:53       ` Oleg Nesterov
@ 2011-08-24 14:02         ` Michal Simek
  0 siblings, 0 replies; 71+ messages in thread
From: Michal Simek @ 2011-08-24 14:02 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Matt Fleming, linux-kernel

Oleg Nesterov wrote:
> On 08/24, Matt Fleming wrote:
>> On Wed, 2011-08-24 at 10:49 +0200, Michal Simek wrote:
>>>> v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
>>>> for adding sigmask to current->blocked" so they need to go through the
>>>> same tree but this patch would benefit from some maintainer ACK's.
>>> Please add there my ACK to it too.
> 
> Thanks Michal.
> 
>>> I will add patches 14-16/43 v2 to microblaze next branch keep them
>>> for a while. I will propose them to Linus tree for v3.2.
>> Actually, I just realised this is where it gets a little complicated. If
>> you take those 3 patches and they're not in Oleg's tree, [PATCH 17/43]
>> doesn't apply cleanly. Fixing 17/43 up so it applies without patches
>> 14-16 would result in something like this in handle_signal(),
>>
>> 	if (!(ka->sa.sa_flags & SA_NODEFER)) {
>> 		block_sigmask(ka, sig);
>> 	}
>> 	return 1;
>>
>> Which Linus would have to fixup to its original form when he merges the
>> two trees. I think all the microblaze patches should go through Oleg's
>> tree,
> 
> Agreed, this looks simpler.
> 
> Michal, unless you object, I am going to add the microblaze changes
> (with your acks) to ptrace branch, it already has 01/43 which adds
> block_sigmask().
> 
> OK?

No problem.

Thanks,
Michal


-- 
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian

^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 43/43] ncpfs: Use set_current_blocked()
  2011-08-19 16:46 ` [PATCH v2 43/43] ncpfs: Use set_current_blocked() Matt Fleming
@ 2011-08-24 17:36   ` Oleg Nesterov
  2011-08-24 17:52     ` Oleg Nesterov
  0 siblings, 1 reply; 71+ messages in thread
From: Oleg Nesterov @ 2011-08-24 17:36 UTC (permalink / raw)
  To: Matt Fleming; +Cc: linux-kernel, Petr Vandrovec, Al Viro, Arnd Bergmann

On 08/19, Matt Fleming wrote:
>
> From: Matt Fleming <matt.fleming@intel.com>
>
> 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, there's no need to hold sighand->siglock while reading
> sighand->action[] because the lock is dropped across the call to
> do_ncp_rpc_call() during which time another thread could modify
> ->action[].

Unlless you object, I am going to add the following into the changelog:

	Note: the current code does the strange things which nobody can
	explain, especially the PF_EXITING/SIGKILL thing. This patch does
	try to change this.

and push the patch into ptrace branch.

Oleg.


^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 43/43] ncpfs: Use set_current_blocked()
  2011-08-24 17:36   ` Oleg Nesterov
@ 2011-08-24 17:52     ` Oleg Nesterov
  2011-08-24 19:08       ` Matt Fleming
  0 siblings, 1 reply; 71+ messages in thread
From: Oleg Nesterov @ 2011-08-24 17:52 UTC (permalink / raw)
  To: Matt Fleming; +Cc: linux-kernel, Petr Vandrovec, Al Viro, Arnd Bergmann

On 08/24, Oleg Nesterov wrote:
>
> Unlless you object, I am going to add the following into the changelog:
>
> 	Note: the current code does the strange things which nobody can
> 	explain, especially the PF_EXITING/SIGKILL thing. This patch does
> 	try to change this.

I mean "does not" of course...

Oleg.


^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask()
  2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
                   ` (42 preceding siblings ...)
  2011-08-19 16:46 ` [PATCH v2 43/43] ncpfs: Use set_current_blocked() Matt Fleming
@ 2011-08-24 18:24 ` Oleg Nesterov
  2011-08-25  4:30   ` Ian Kent
  43 siblings, 1 reply; 71+ messages in thread
From: Oleg Nesterov @ 2011-08-24 18:24 UTC (permalink / raw)
  To: Matt Fleming
  Cc: linux-kernel, linux-arch, Ian Kent, Jan Harkes, Petr Vandrovec

(add linux-arch)

On 08/19, Matt Fleming wrote:
>
>  arch/alpha/kernel/signal.c         |   31 ++++++++----------------
>  arch/arm/kernel/signal.c           |   24 ++++++------------
>  arch/avr32/kernel/signal.c         |   26 ++++++--------------
>  arch/blackfin/kernel/signal.c      |   17 +++----------
>  arch/cris/arch-v10/kernel/signal.c |   34 +++++++++-----------------
>  arch/cris/arch-v32/kernel/signal.c |   37 ++++++++--------------------
>  arch/frv/kernel/signal.c           |   32 ++++++++-----------------
>  arch/h8300/kernel/signal.c         |   33 +++++++-------------------
>  arch/ia64/kernel/signal.c          |   15 +----------
>  arch/m32r/kernel/signal.c          |   12 +--------
>  arch/m68k/kernel/signal_mm.c       |   22 +++++++----------
>  arch/m68k/kernel/signal_no.c       |   28 +++++++---------------
>  arch/microblaze/kernel/signal.c    |   42 +++++++++++++--------------------
>  arch/mips/kernel/signal.c          |   27 ++++-----------------
>  arch/mips/kernel/signal32.c        |   20 +++------------
>  arch/mips/kernel/signal_n32.c      |   10 +------
>  arch/mn10300/kernel/signal.c       |   32 ++++++++-----------------
>  arch/openrisc/kernel/signal.c      |   45 +++++++++++++++--------------------
>  arch/parisc/kernel/signal.c        |   12 +--------
>  arch/powerpc/kernel/signal.c       |   13 +--------
>  arch/powerpc/kernel/signal_32.c    |   11 ++++----
>  arch/s390/kernel/compat_signal.c   |    6 +----
>  arch/s390/kernel/signal.c          |    6 +----
>  arch/score/kernel/signal.c         |   13 ++--------
>  arch/sh/kernel/signal_32.c         |   35 ++++++++--------------------
>  arch/sh/kernel/signal_64.c         |   40 ++++++++------------------------
>  arch/sparc/kernel/signal32.c       |   17 ++-----------
>  arch/sparc/kernel/signal_32.c      |   28 +++++++---------------
>  arch/sparc/kernel/signal_64.c      |   29 ++++++++---------------
>  arch/tile/kernel/compat_signal.c   |    5 +---
>  arch/tile/kernel/signal.c          |   13 +--------
>  arch/um/kernel/signal.c            |   28 +++++++---------------
>  arch/um/sys-i386/signal.c          |   12 +--------
>  arch/um/sys-x86_64/signal.c        |    6 +----
>  arch/unicore32/kernel/signal.c     |   13 +--------
>  arch/x86/kernel/signal.c           |    6 +----
>  arch/xtensa/kernel/signal.c        |   35 ++++++++-------------------
>  fs/autofs4/waitq.c                 |   13 +++-------
>  fs/coda/upcall.c                   |   19 ++++++--------
>  fs/dlm/user.c                      |    1 -
>  fs/ncpfs/sock.c                    |   15 ++++--------
>  include/linux/signal.h             |    1 +
>  kernel/signal.c                    |   21 ++++++++++++++++

Thanks to those who replied.

I applied the whole series with a few acks we got. Other maintainers
do not care, I guess.

Oleg.


^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 43/43] ncpfs: Use set_current_blocked()
  2011-08-24 17:52     ` Oleg Nesterov
@ 2011-08-24 19:08       ` Matt Fleming
  0 siblings, 0 replies; 71+ messages in thread
From: Matt Fleming @ 2011-08-24 19:08 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: linux-kernel, Petr Vandrovec, Al Viro, Arnd Bergmann

On Wed, 2011-08-24 at 19:52 +0200, Oleg Nesterov wrote:
> On 08/24, Oleg Nesterov wrote:
> >
> > Unlless you object, I am going to add the following into the changelog:
> >
> > 	Note: the current code does the strange things which nobody can
> > 	explain, especially the PF_EXITING/SIGKILL thing. This patch does
> > 	try to change this.
> 
> I mean "does not" of course...

Yeah, I think you've got an extra "the" in the first sentence though, it
should say,

	"Note: the current code does strange things..."

But otherwise, yeah, that sounds good to me.


^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask()
  2011-08-24 18:24 ` [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Oleg Nesterov
@ 2011-08-25  4:30   ` Ian Kent
  2011-08-25 15:31     ` Oleg Nesterov
  0 siblings, 1 reply; 71+ messages in thread
From: Ian Kent @ 2011-08-25  4:30 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Matt Fleming, linux-kernel, linux-arch, Jan Harkes, Petr Vandrovec

On Wed, 2011-08-24 at 20:24 +0200, Oleg Nesterov wrote:
> (add linux-arch)
> 
> On 08/19, Matt Fleming wrote:
> >
> >  arch/alpha/kernel/signal.c         |   31 ++++++++----------------
> >  arch/arm/kernel/signal.c           |   24 ++++++------------
> >  arch/avr32/kernel/signal.c         |   26 ++++++--------------
> >  arch/blackfin/kernel/signal.c      |   17 +++----------
> >  arch/cris/arch-v10/kernel/signal.c |   34 +++++++++-----------------
> >  arch/cris/arch-v32/kernel/signal.c |   37 ++++++++--------------------
> >  arch/frv/kernel/signal.c           |   32 ++++++++-----------------
> >  arch/h8300/kernel/signal.c         |   33 +++++++-------------------
> >  arch/ia64/kernel/signal.c          |   15 +----------
> >  arch/m32r/kernel/signal.c          |   12 +--------
> >  arch/m68k/kernel/signal_mm.c       |   22 +++++++----------
> >  arch/m68k/kernel/signal_no.c       |   28 +++++++---------------
> >  arch/microblaze/kernel/signal.c    |   42 +++++++++++++--------------------
> >  arch/mips/kernel/signal.c          |   27 ++++-----------------
> >  arch/mips/kernel/signal32.c        |   20 +++------------
> >  arch/mips/kernel/signal_n32.c      |   10 +------
> >  arch/mn10300/kernel/signal.c       |   32 ++++++++-----------------
> >  arch/openrisc/kernel/signal.c      |   45 +++++++++++++++--------------------
> >  arch/parisc/kernel/signal.c        |   12 +--------
> >  arch/powerpc/kernel/signal.c       |   13 +--------
> >  arch/powerpc/kernel/signal_32.c    |   11 ++++----
> >  arch/s390/kernel/compat_signal.c   |    6 +----
> >  arch/s390/kernel/signal.c          |    6 +----
> >  arch/score/kernel/signal.c         |   13 ++--------
> >  arch/sh/kernel/signal_32.c         |   35 ++++++++--------------------
> >  arch/sh/kernel/signal_64.c         |   40 ++++++++------------------------
> >  arch/sparc/kernel/signal32.c       |   17 ++-----------
> >  arch/sparc/kernel/signal_32.c      |   28 +++++++---------------
> >  arch/sparc/kernel/signal_64.c      |   29 ++++++++---------------
> >  arch/tile/kernel/compat_signal.c   |    5 +---
> >  arch/tile/kernel/signal.c          |   13 +--------
> >  arch/um/kernel/signal.c            |   28 +++++++---------------
> >  arch/um/sys-i386/signal.c          |   12 +--------
> >  arch/um/sys-x86_64/signal.c        |    6 +----
> >  arch/unicore32/kernel/signal.c     |   13 +--------
> >  arch/x86/kernel/signal.c           |    6 +----
> >  arch/xtensa/kernel/signal.c        |   35 ++++++++-------------------
> >  fs/autofs4/waitq.c                 |   13 +++-------
> >  fs/coda/upcall.c                   |   19 ++++++--------
> >  fs/dlm/user.c                      |    1 -
> >  fs/ncpfs/sock.c                    |   15 ++++--------
> >  include/linux/signal.h             |    1 +
> >  kernel/signal.c                    |   21 ++++++++++++++++
> 
> Thanks to those who replied.
> 
> I applied the whole series with a few acks we got. Other maintainers
> do not care, I guess.

I wouldn't say that, I didn't NAK it for autofs4.
I do appreciate the cc on the post, thanks.

Ian



^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask()
  2011-08-25  4:30   ` Ian Kent
@ 2011-08-25 15:31     ` Oleg Nesterov
  0 siblings, 0 replies; 71+ messages in thread
From: Oleg Nesterov @ 2011-08-25 15:31 UTC (permalink / raw)
  To: Ian Kent
  Cc: Matt Fleming, linux-kernel, linux-arch, Jan Harkes, Petr Vandrovec

On 08/25, Ian Kent wrote:
>
> On Wed, 2011-08-24 at 20:24 +0200, Oleg Nesterov wrote:
> >
> > >  fs/autofs4/waitq.c                 |   13 +++-------
> >
> > I applied the whole series with a few acks we got. Other maintainers
> > do not care, I guess.
>
> I wouldn't say that, I didn't NAK it for autofs4.

I meant, "Hopefully other maintainers do not object".

We need to resubmit this patch, set_current_blocked() is not
exported. Your ack is welcomed ;)

Oleg.


^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 03/43] arm: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 ` [PATCH v2 03/43] arm: " Matt Fleming
@ 2011-08-25 17:15   ` Will Deacon
  2011-08-26 10:06     ` Matt Fleming
  0 siblings, 1 reply; 71+ messages in thread
From: Will Deacon @ 2011-08-25 17:15 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Oleg Nesterov, linux-kernel, Russell King, Arnd Bergmann,
	Dave Martin, Nicolas Pitre

Hi Matt,

On Fri, Aug 19, 2011 at 05:46:19PM +0100, Matt Fleming wrote:
> From: Matt Fleming <matt.fleming@linux.intel.com>
> 
> As described in e6fa16ab ("signal: sigprocmask() should do
> retarget_shared_pending()") the modification of current->blocked is
> incorrect as we need to check for shared signals we're about to block.
> 
> Also, use the new helper function block_sigmask() 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.
> 
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Arnd Bergmann <arnd.bergmann@linaro.org>
> Cc: Dave Martin <dave.martin@linaro.org>
> Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
> Cc: Will Deacon <will.deacon@arm.com>
> Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
> ---
> 
> v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
> for adding sigmask to current->blocked" so they need to go through the
> same tree but this patch would benefit from some maintainer ACK's.
> 
> Will, I dropped your Acked-by because I felt this patch changed quite
> dramatically since v1 and warrants another review. I hope that's OK.

Ok. Looks like the only change from v1 is calling block_sigmask. which does
what was previously done inline (in v1).

So you can keep my ack if you like!

Will

^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 03/43] arm: Use set_current_blocked() and block_sigmask()
  2011-08-25 17:15   ` Will Deacon
@ 2011-08-26 10:06     ` Matt Fleming
  2011-08-26 14:18       ` Oleg Nesterov
  0 siblings, 1 reply; 71+ messages in thread
From: Matt Fleming @ 2011-08-26 10:06 UTC (permalink / raw)
  To: Will Deacon
  Cc: Oleg Nesterov, linux-kernel, Russell King, Arnd Bergmann,
	Dave Martin, Nicolas Pitre

On Thu, 2011-08-25 at 18:15 +0100, Will Deacon wrote:
> Ok. Looks like the only change from v1 is calling block_sigmask. which does
> what was previously done inline (in v1).
> 
> So you can keep my ack if you like!

Thanks!

Oleg, could you add Will's Acked-by?

-- 
Matt Fleming, Intel Open Source Technology Center


^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 03/43] arm: Use set_current_blocked() and block_sigmask()
  2011-08-26 10:06     ` Matt Fleming
@ 2011-08-26 14:18       ` Oleg Nesterov
  0 siblings, 0 replies; 71+ messages in thread
From: Oleg Nesterov @ 2011-08-26 14:18 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Will Deacon, linux-kernel, Russell King, Arnd Bergmann,
	Dave Martin, Nicolas Pitre

On 08/26, Matt Fleming wrote:
>
> On Thu, 2011-08-25 at 18:15 +0100, Will Deacon wrote:
> > Ok. Looks like the only change from v1 is calling block_sigmask. which does
> > what was previously done inline (in v1).
> >
> > So you can keep my ack if you like!
>
> Thanks!

Yes, thanks.

> Oleg, could you add Will's Acked-by?

Ooooh. Will, Matt, I really hope you won't insist. The problem is,
I already pushed these changes, I'd like to avoid another test of
my poor git skills ;)

Oleg.


^ permalink raw reply	[flat|nested] 71+ messages in thread

* Re: [PATCH v2 32/43] tile: Use set_current_blocked() and block_sigmask()
  2011-08-19 16:46 ` [PATCH v2 32/43] tile: " Matt Fleming
@ 2011-08-29 20:44   ` Chris Metcalf
  0 siblings, 0 replies; 71+ messages in thread
From: Chris Metcalf @ 2011-08-29 20:44 UTC (permalink / raw)
  To: Matt Fleming; +Cc: Oleg Nesterov, linux-kernel, Arnd Bergmann

On 8/19/2011 12:46 PM, Matt Fleming wrote:
> From: Matt Fleming <matt.fleming@intel.com>
>
> 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 block_sigmask() 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.
>
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Chris Metcalf <cmetcalf@tilera.com>
> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
> ---
>
> v2 of this patch depends on "[PATCH 01/43] signal: Add block_sigmask()
> for adding sigmask to current->blocked" so they need to go through the
> same tree but this patch would benefit from some maintainer ACK's.
>
> Chris, I dropped your Acked-by because I felt this patch changed quite
> dramatically since v1 and warrants another review. I hope that's OK.
>
>
>  arch/tile/kernel/compat_signal.c |    5 +----
>  arch/tile/kernel/signal.c        |   13 ++-----------
>  2 files changed, 3 insertions(+), 15 deletions(-)
>

Still looks good to me :-)

Acked-by: Chris Metcalf <cmetcalf@tilera.com>

Sorry for the late reply; I was away on vacation.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


^ permalink raw reply	[flat|nested] 71+ messages in thread

end of thread, other threads:[~2011-08-29 20:44 UTC | newest]

Thread overview: 71+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-19 16:46 [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Matt Fleming
2011-08-19 16:46 ` [PATCH 01/43] signal: Add block_sigmask() for adding sigmask to current->blocked Matt Fleming
2011-08-22 10:19   ` Matt Fleming
2011-08-22 14:01     ` Oleg Nesterov
2011-08-22 14:04       ` Oleg Nesterov
2011-08-22 15:56       ` Matt Fleming
2011-08-19 16:46 ` [PATCH v2 02/43] alpha: Use set_current_blocked() and block_sigmask() Matt Fleming
2011-08-19 16:46 ` [PATCH v2 03/43] arm: " Matt Fleming
2011-08-25 17:15   ` Will Deacon
2011-08-26 10:06     ` Matt Fleming
2011-08-26 14:18       ` Oleg Nesterov
2011-08-19 16:46 ` [PATCH v2 04/43] avr32: Don't mask signals in the error path Matt Fleming
2011-08-19 16:46 ` [PATCH v2 05/43] avr32: use set_current_blocked() in handle_signal/sys_rt_sigreturn Matt Fleming
2011-08-19 16:46 ` [PATCH v2 06/43] avr32: Use block_sigmask() Matt Fleming
2011-08-19 16:46 ` [PATCH v2 07/43] blackfin: Use set_current_blocked() and block_sigmask() Matt Fleming
2011-08-20  4:00   ` Mike Frysinger
2011-08-20  8:36     ` Matt Fleming
2011-08-20 17:31       ` Mike Frysinger
2011-08-19 16:46 ` [PATCH v2 08/43] cris: " Matt Fleming
2011-08-19 16:46 ` [PATCH v2 09/43] frv: " Matt Fleming
2011-08-19 16:46 ` [PATCH v2 10/43] h8300: " Matt Fleming
2011-08-19 16:46 ` [PATCH v2 11/43] ia64: " Matt Fleming
2011-08-19 16:46 ` [PATCH v2 12/43] m32r: " Matt Fleming
2011-08-19 16:46 ` [PATCH v2 13/43] m68k: " Matt Fleming
2011-08-24  4:38   ` Greg Ungerer
2011-08-19 16:46 ` [PATCH v2 14/43] microblaze: Don't reimplement force_sigsegv() Matt Fleming
2011-08-19 16:46 ` [PATCH v2 15/43] microblaze: No need to reset handler if SA_ONESHOT Matt Fleming
2011-08-19 16:46 ` [PATCH v2 16/43] microblaze: Fix signal masking Matt Fleming
2011-08-19 16:46 ` [PATCH v2 17/43] microblaze: Use set_current_blocked() and block_sigmask() Matt Fleming
2011-08-24  8:49   ` Michal Simek
2011-08-24 10:21     ` Matt Fleming
2011-08-24 13:53       ` Oleg Nesterov
2011-08-24 14:02         ` Michal Simek
2011-08-19 16:46 ` [PATCH v2 18/43] MIPS: " Matt Fleming
2011-08-19 17:27   ` Ralf Baechle
2011-08-19 16:46 ` [PATCH v2 19/43] mn10300: " Matt Fleming
2011-08-19 16:46 ` [PATCH v2 20/43] OpenRISC: Don't reimplement force_sigsegv() Matt Fleming
2011-08-19 16:46 ` [PATCH v2 21/43] OpenRISC: No need to reset handler if SA_ONESHOT Matt Fleming
2011-08-19 16:46 ` [PATCH v2 22/43] OpenRISC: Don't mask signals if we fail to setup signal stack Matt Fleming
2011-08-19 16:46 ` [PATCH v2 23/43] OpenRISC: Use set_current_blocked() and block_sigmask() Matt Fleming
2011-08-19 16:46 ` [PATCH v2 24/43] parisc: " Matt Fleming
2011-08-19 16:46 ` [PATCH v2 25/43] powerpc: " Matt Fleming
2011-08-19 16:46 ` [PATCH 26/43] [S390]: Use block_sigmask() Matt Fleming
2011-08-23  6:04   ` Martin Schwidefsky
2011-08-19 16:46 ` [PATCH v2 27/43] score: Don't mask signals if we fail to setup signal stack Matt Fleming
2011-08-19 16:46 ` [PATCH v2 28/43] score: Use set_current_blocked() and block_sigmask() Matt Fleming
2011-08-19 16:46 ` [PATCH v2 29/43] sh: No need to reset handler if SA_ONESHOT Matt Fleming
2011-08-19 16:46 ` [PATCH v2 30/43] sh: Use set_current_blocked() and block_sigmask() Matt Fleming
2011-08-19 16:46 ` [PATCH v2 31/43] sparc: " Matt Fleming
2011-08-19 16:46 ` [PATCH v2 32/43] tile: " Matt Fleming
2011-08-29 20:44   ` Chris Metcalf
2011-08-19 16:46 ` [PATCH v2 33/43] um: " Matt Fleming
2011-08-19 16:46 ` [PATCH v2 34/43] um: Don't restore current->blocked on error Matt Fleming
2011-08-19 16:46 ` [PATCH v2 35/43] unicore32: Use set_current_blocked() and block_sigmask() Matt Fleming
2011-08-22  2:15   ` Guan Xuetao
2011-08-22 10:26     ` Matt Fleming
2011-08-24  2:03       ` Guan Xuetao
2011-08-19 16:46 ` [PATCH v2 36/43] xtensa: Don't reimplement force_sigsegv() Matt Fleming
2011-08-19 16:46 ` [PATCH v2 37/43] xtensa: No need to reset handler if SA_ONESHOT Matt Fleming
2011-08-19 16:46 ` [PATCH v2 38/43] xtensa: Don't mask signals if we fail to setup signal stack Matt Fleming
2011-08-19 16:46 ` [PATCH v2 39/43] xtensa: Use set_current_blocked() and block_sigmask() Matt Fleming
2011-08-19 16:46 ` [PATCH v2 40/43] autofs4: Use set_current_blocked() Matt Fleming
2011-08-19 16:46 ` [PATCH v2 41/43] coda: " Matt Fleming
2011-08-19 16:46 ` [PATCH v2 42/43] dlm: Remove another superfluous call to recalc_sigpending() Matt Fleming
2011-08-19 16:46 ` [PATCH v2 43/43] ncpfs: Use set_current_blocked() Matt Fleming
2011-08-24 17:36   ` Oleg Nesterov
2011-08-24 17:52     ` Oleg Nesterov
2011-08-24 19:08       ` Matt Fleming
2011-08-24 18:24 ` [PATCH v2 00/43] signal: set_current_blocked() and block_sigmask() Oleg Nesterov
2011-08-25  4:30   ` Ian Kent
2011-08-25 15:31     ` Oleg Nesterov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.