Skip to contentSkip to conversation

signals: sys_ssetmask/sys_rt_sigsuspend should use set_current_blocked()

PATCH In review Oleg Nesterov 3 participants 3 messages Jul 11, 2011 – Jul 13, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 signals: sys_ssetmask/sys_rt_sigsuspend should use set_current_blocked()

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.

---

 kernel/signal.c |   17 +++++------------
 kernel/compat.c |    5 +----
 2 files changed, 6 insertions(+), 16 deletions(-)
kernel/signal.c renamed from kernel/signal.c~4_sigsuspend +5 -12
@@ -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();
kernel/compat.c renamed from kernel/compat.c~4_sigsuspend +1 -4
@@ -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();
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Mon, 11 Jul 2011 18:01:02 +0200 Oleg Nesterov <[email protected]> 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.

Acked-by on v1 1/1
#2 lore raw
In reply to Oleg Nesterov
Quoted 10 lines · Oleg Nesterov

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.

Signature · 1 line
tejun