mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	daniel@hozac.com, roland@redhat.com,
	Pavel Emelyanov <xemul@sw.ru>,
	Atsushi Tsuji <a-tsuji@bk.jp.nec.com>
Subject: Re: + signals-introduce-kill_pid_ns_info.patch added to -mm tree
Date: Wed, 23 Jul 2008 19:14:58 +0400	[thread overview]
Message-ID: <20080723151458.GA2983@tv-sign.ru> (raw)
In-Reply-To: <m1ljzshfqb.fsf@frodo.ebiederm.org>

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;


           reply	other threads:[~2008-07-23 15:11 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <m1ljzshfqb.fsf@frodo.ebiederm.org>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080723151458.GA2983@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=a-tsuji@bk.jp.nec.com \
    --cc=akpm@linux-foundation.org \
    --cc=daniel@hozac.com \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roland@redhat.com \
    --cc=xemul@sw.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®