mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] signals: do_tkill: don't use tasklist_lock
@ 2008-03-07  9:58 Oleg Nesterov
  2008-03-07 10:50 ` Christoph Hellwig
  2008-03-07 19:31 ` [PATCH] signals: do_tkill: don't use tasklist_lock Roland McGrath
  0 siblings, 2 replies; 11+ messages in thread
From: Oleg Nesterov @ 2008-03-07  9:58 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Eric W. Biederman, Ingo Molnar, Roland McGrath, linux-kernel

(sorry to all, re-sending with the correct Andrew's email)

Convert do_tkill() to use rcu_read_lock() + lock_task_sighand() to avoid taking
tasklist lock.

Note that we don't return an error if lock_task_sighand() fails, we pretend the
task dies after receiving the signal. Otherwise, we should fight with the nasty
races with mt-exec without having any advantage.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- 25/kernel/signal.c~2_TKILL_NO_TASKLIST	2008-03-07 10:47:02.000000000 +0300
+++ 25/kernel/signal.c	2008-03-07 12:20:34.000000000 +0300
@@ -2194,6 +2194,7 @@ static int do_tkill(int tgid, int pid, i
 	int error;
 	struct siginfo info;
 	struct task_struct *p;
+	unsigned long flags;
 
 	error = -ESRCH;
 	info.si_signo = sig;
@@ -2202,7 +2203,7 @@ static int do_tkill(int tgid, int pid, i
 	info.si_pid = task_tgid_vnr(current);
 	info.si_uid = current->uid;
 
-	read_lock(&tasklist_lock);
+	rcu_read_lock();
 	p = find_task_by_vpid(pid);
 	if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
 		error = check_kill_permission(sig, &info, p);
@@ -2210,13 +2211,12 @@ static int do_tkill(int tgid, int pid, i
 		 * The null signal is a permissions and process existence
 		 * probe.  No signal is actually delivered.
 		 */
-		if (!error && sig && p->sighand) {
-			spin_lock_irq(&p->sighand->siglock);
+		if (!error && sig && lock_task_sighand(p, &flags)) {
 			error = specific_send_sig_info(sig, &info, p);
-			spin_unlock_irq(&p->sighand->siglock);
+			unlock_task_sighand(p, &flags);
 		}
 	}
-	read_unlock(&tasklist_lock);
+	rcu_read_unlock();
 
 	return error;
 }


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

end of thread, other threads:[~2008-03-11  2:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-07  9:58 [PATCH] signals: do_tkill: don't use tasklist_lock Oleg Nesterov
2008-03-07 10:50 ` Christoph Hellwig
2008-03-07 11:05   ` [PATCH] signals-do_tkill-dont-use-tasklist_lock-comment Oleg Nesterov
2008-03-07 19:31 ` [PATCH] signals: do_tkill: don't use tasklist_lock Roland McGrath
2008-03-07 20:13   ` Oleg Nesterov
2008-03-07 20:23     ` Oleg Nesterov
2008-03-07 21:19     ` Roland McGrath
2008-03-07 21:32       ` Oleg Nesterov
2008-03-07 21:51         ` Roland McGrath
2008-03-08 18:05           ` mt-exec && signals Oleg Nesterov
2008-03-11  2:41             ` Roland McGrath

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

all inboxes | Powered by JetHome®