[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20080723151458.GA2983@tv-sign.ru>
Date: Wed, 23 Jul 2008 19:14:58 +0400
From: Oleg Nesterov <oleg@...sign.ru>
To: "Eric W. Biederman" <ebiederm@...ssion.com>
Cc: akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
daniel@...ac.com, roland@...hat.com, Pavel Emelyanov <xemul@...ru>,
Atsushi Tsuji <a-tsuji@...jp.nec.com>
Subject: Re: + signals-introduce-kill_pid_ns_info.patch added to -mm tree
s/mm-commits/lkml/
On 07/23, Eric W. Biederman wrote:
>
> Oleg Nesterov <oleg@...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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists