summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2011-04-27 19:54:20 +0200
committerOleg Nesterov <oleg@redhat.com>2011-04-28 13:01:36 +0200
commit73ef4aeb61b53fce464a7e24ef03a26f98b2f617 (patch)
tree15acc5d7ded643ccd1da1d502033822a2452497c /kernel
parentfec9993db093acfc3999a364e31f8adae41fcb28 (diff)
downloadop-kernel-dev-73ef4aeb61b53fce464a7e24ef03a26f98b2f617.zip
op-kernel-dev-73ef4aeb61b53fce464a7e24ef03a26f98b2f617.tar.gz
signal: sigprocmask: narrow the scope of ->siglock
No functional changes, preparation to simplify the review of the next change. 1. We can read current->block lockless, nobody else can ever change this mask. 2. Calculate the resulting sigset_t outside of ->siglock into the temporary variable, then take ->siglock and change ->blocked. Also, kill the stale comment about BKL. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Reviewed-by: Matt Fleming <matt.fleming@linux.intel.com> Acked-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/signal.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/kernel/signal.c b/kernel/signal.c
index 707736e..e8308e32 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2300,12 +2300,6 @@ long do_no_restart_syscall(struct restart_block *param)
}
/*
- * We don't need to get the kernel lock - this is all local to this
- * particular thread.. (and that's good, because this is _heavily_
- * used by various programs)
- */
-
-/*
* This is also useful for kernel threads that want to temporarily
* (or permanently) block certain signals.
*
@@ -2315,30 +2309,33 @@ long do_no_restart_syscall(struct restart_block *param)
*/
int sigprocmask(int how, sigset_t *set, sigset_t *oldset)
{
- int error;
+ struct task_struct *tsk = current;
+ sigset_t newset;
- spin_lock_irq(&current->sighand->siglock);
+ /* Lockless, only current can change ->blocked, never from irq */
if (oldset)
- *oldset = current->blocked;
+ *oldset = tsk->blocked;
- error = 0;
switch (how) {
case SIG_BLOCK:
- sigorsets(&current->blocked, &current->blocked, set);
+ sigorsets(&newset, &tsk->blocked, set);
break;
case SIG_UNBLOCK:
- signandsets(&current->blocked, &current->blocked, set);
+ signandsets(&newset, &tsk->blocked, set);
break;
case SIG_SETMASK:
- current->blocked = *set;
+ newset = *set;
break;
default:
- error = -EINVAL;
+ return -EINVAL;
}
+
+ spin_lock_irq(&tsk->sighand->siglock);
+ tsk->blocked = newset;
recalc_sigpending();
- spin_unlock_irq(&current->sighand->siglock);
+ spin_unlock_irq(&tsk->sighand->siglock);
- return error;
+ return 0;
}
/**
OpenPOWER on IntegriCloud