lkml.org 
[lkml]   [2008]   [Jul]   [23]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
DateWed, 23 Jul 2008 19:14:58 +0400
FromOleg Nesterov <>
SubjectRe: + 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@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;


\
 
 \ /
  Last update: 2008-07-23 17:13    [from the cache]
©2003-2008