mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: + signals-introduce-kill_pid_ns_info.patch added to -mm tree
       [not found]   ` <m1ljzshfqb.fsf@frodo.ebiederm.org>
@ 2008-07-23 15:14     ` Oleg Nesterov
  0 siblings, 0 replies; only message in thread
From: Oleg Nesterov @ 2008-07-23 15:14 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: akpm, linux-kernel, daniel, roland, Pavel Emelyanov, Atsushi Tsuji

s/mm-commits/lkml/

On 07/23, Eric W. Biederman wrote:
>
> Oleg Nesterov <oleg@tv-sign.ru> writes:
> 
> > <troll mode on>
> >
> > 	Sadly, I can't see some really bad problems with this patch ;)
> >
> > 	Because with this change it is much harder to remove tasklist_lock
> > 	for the "kill(-1)" case.
> >
> > 	kill(-1) is not time critical, the problem it holds tasklist_lock.
> > 	And this patch makes things worse for the global namespace.
> 
> Slightly.  It leaves the code very readable in all namespaces, and it
> puts all of the logic in one function where it can be more easily
> worked with.
> 
> I have yet to see an instance where we can safely drop tasklist_lock.  In
> the kill -1 case.

Afaics, all we need is the patch below. Then we can s/tasklist/rcu/ + add
fat comment to explain why this is safe.

Oleg.

--- kernel/signal.c
+++ kernel/signal.c
@@ -1110,6 +1110,23 @@ out_unlock:
 EXPORT_SYMBOL_GPL(kill_pid_info_as_uid);
 
 /*
+ * Same as group_send_sig_info(), but make sure we don't race
+ * with exec() when we don't hold tasklist_lock
+ */
+int kill_xxx(int sig, struct siginfo *info, struct task_struct *g)
+{
+	struct task_struct *p = g;
+
+	do {
+		ret = group_send_sig_info(sig, info, p);
+		if (ret != -ESRCH)
+			break;
+	} while_each_thread(g, p);
+
+	return ret;
+}
+
+/*
  * kill_something_info() interprets pid in interesting ways just like kill(2).
  *
  * POSIX specifies that kill(-1,sig) is unspecified, but what we have
@@ -1137,7 +1154,9 @@ static int kill_something_info(int sig, 
 
 		for_each_process(p) {
 			if (p->pid > 1 && !same_thread_group(p, current)) {
-				int err = group_send_sig_info(sig, info, p);
+				int err = kill_xxx(sig, info, p);
+				if (err = -ESRCH) /* not possible under tasklist */
+					continue;
 				++count;
 				if (err != -EPERM)
 					retval = err;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-07-23 15:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <200807220822.m6M8M1Xl018412@imap1.linux-foundation.org>
     [not found] ` <20080722141655.GA3345@tv-sign.ru>
     [not found]   ` <m1ljzshfqb.fsf@frodo.ebiederm.org>
2008-07-23 15:14     ` + signals-introduce-kill_pid_ns_info.patch added to -mm tree Oleg Nesterov

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®