public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] signals: sys_ssetmask/sys_rt_sigsuspend should use set_current_blocked()
@ 2011-07-11 16:01 Oleg Nesterov
  2011-07-12 18:17 ` Matt Fleming
  2011-07-13 12:27 ` Tejun Heo
  0 siblings, 2 replies; 3+ messages in thread
From: Oleg Nesterov @ 2011-07-11 16:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Tejun Heo, Matt Fleming, linux-kernel

sys_ssetmask(), sys_rt_sigsuspend() and compat_sys_rt_sigsuspend()
change ->blocked directly. This is not correct, see the changelog in
e6fa16ab "signal: sigprocmask() should do retarget_shared_pending()"

Change them to use set_current_blocked().

Another change is that now we are doing ->saved_sigmask = ->blocked
lockless, it doesn't make any sense to do this under ->siglock.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---

 kernel/signal.c |   17 +++++------------
 kernel/compat.c |    5 +----
 2 files changed, 6 insertions(+), 16 deletions(-)

--- ptrace/kernel/signal.c~4_sigsuspend	2011-07-10 16:19:27.000000000 +0200
+++ ptrace/kernel/signal.c	2011-07-11 17:27:48.000000000 +0200
@@ -2986,15 +2986,11 @@ SYSCALL_DEFINE0(sgetmask)
 
 SYSCALL_DEFINE1(ssetmask, int, newmask)
 {
-	int old;
-
-	spin_lock_irq(&current->sighand->siglock);
-	old = current->blocked.sig[0];
+	int old = current->blocked.sig[0];
+	sigset_t newset;
 
-	siginitset(&current->blocked, newmask & ~(sigmask(SIGKILL)|
-						  sigmask(SIGSTOP)));
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	siginitset(&newset, newmask & ~(sigmask(SIGKILL) | sigmask(SIGSTOP)));
+	set_current_blocked(&newset);
 
 	return old;
 }
@@ -3051,11 +3047,8 @@ SYSCALL_DEFINE2(rt_sigsuspend, sigset_t 
 		return -EFAULT;
 	sigdelsetmask(&newset, sigmask(SIGKILL)|sigmask(SIGSTOP));
 
-	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();
--- ptrace/kernel/compat.c~4_sigsuspend	2011-05-26 14:48:21.000000000 +0200
+++ ptrace/kernel/compat.c	2011-07-11 17:53:57.000000000 +0200
@@ -991,11 +991,8 @@ asmlinkage long compat_sys_rt_sigsuspend
 	sigset_from_compat(&newset, &newset32);
 	sigdelsetmask(&newset, sigmask(SIGKILL)|sigmask(SIGSTOP));
 
-	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();


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

* Re: [PATCH] signals: sys_ssetmask/sys_rt_sigsuspend should use set_current_blocked()
  2011-07-11 16:01 [PATCH] signals: sys_ssetmask/sys_rt_sigsuspend should use set_current_blocked() Oleg Nesterov
@ 2011-07-12 18:17 ` Matt Fleming
  2011-07-13 12:27 ` Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Matt Fleming @ 2011-07-12 18:17 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Andrew Morton, Tejun Heo, linux-kernel

On Mon, 11 Jul 2011 18:01:02 +0200
Oleg Nesterov <oleg@redhat.com> wrote:

> sys_ssetmask(), sys_rt_sigsuspend() and compat_sys_rt_sigsuspend()
> change ->blocked directly. This is not correct, see the changelog in
> e6fa16ab "signal: sigprocmask() should do retarget_shared_pending()"
> 
> Change them to use set_current_blocked().
> 
> Another change is that now we are doing ->saved_sigmask = ->blocked
> lockless, it doesn't make any sense to do this under ->siglock.
> 
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>

Reviewed-by: Matt Fleming <matt.fleming@linux.intel.com>

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

* Re: [PATCH] signals: sys_ssetmask/sys_rt_sigsuspend should use set_current_blocked()
  2011-07-11 16:01 [PATCH] signals: sys_ssetmask/sys_rt_sigsuspend should use set_current_blocked() Oleg Nesterov
  2011-07-12 18:17 ` Matt Fleming
@ 2011-07-13 12:27 ` Tejun Heo
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2011-07-13 12:27 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Andrew Morton, Matt Fleming, linux-kernel

On Mon, Jul 11, 2011 at 06:01:02PM +0200, Oleg Nesterov wrote:
> sys_ssetmask(), sys_rt_sigsuspend() and compat_sys_rt_sigsuspend()
> change ->blocked directly. This is not correct, see the changelog in
> e6fa16ab "signal: sigprocmask() should do retarget_shared_pending()"
> 
> Change them to use set_current_blocked().
> 
> Another change is that now we are doing ->saved_sigmask = ->blocked
> lockless, it doesn't make any sense to do this under ->siglock.
> 
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>

Acked-by: Tejun Heo <tj@kernel.org>

-- 
tejun

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

end of thread, other threads:[~2011-07-13 12:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-11 16:01 [PATCH] signals: sys_ssetmask/sys_rt_sigsuspend should use set_current_blocked() Oleg Nesterov
2011-07-12 18:17 ` Matt Fleming
2011-07-13 12:27 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox