Linux Container Development
 help / color / mirror / Atom feed
From: Daniel Hokka Zakrisson <daniel-nym3zxDgnZcAvxtiuMwx3w@public.gmane.org>
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org,
	oleg-6lXkIZvqkOAvJsYlp49lxw@public.gmane.org,
	akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org,
	ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org
Subject: [PATCH 2/2] signals: replace p->pid == 1 check with a check for task_child_reaper
Date: Thu, 17 Jul 2008 10:56:33 -0400	[thread overview]
Message-ID: <487F5DA1.6000107@hozac.com> (raw)

p->pid == 1 is insufficient when there are multiple pid namespaces.
Instead, check whether the task is in the current task's
child reaper's thread group.

Signed-off-by: Daniel Hokka Zakrisson <daniel-nym3zxDgnZcAvxtiuMwx3w@public.gmane.org>

diff --git a/kernel/signal.c b/kernel/signal.c
index 93713a5..be932b9 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1142,10 +1142,20 @@ static int kill_something_info(int sig, struct 
siginfo *info, int pid)
  				pid ? find_vpid(-pid) : task_pgrp(current));
  	} else {
  		int retval = 0, count = 0;
-		struct task_struct * p;
+		struct task_struct *p, *reaper = task_child_reaper(current);
+
+		/*
+		 * The reaper has died, so there's probably a
+		 * SIGKILL pending. Return.
+		 */
+		if (unlikely(!reaper)) {
+			ret = -ESRCH;
+			goto out;
+		}

  		for_each_process(p) {
-			if (p->pid > 1 && !same_thread_group(p, current) &&
+			if (!same_thread_group(p, reaper) &&
+			    !same_thread_group(p, current) &&
  			    task_in_pid_ns(p, current->nsproxy->pid_ns)) {
  				int err = group_send_sig_info(sig, info, p);
  				++count;
@@ -1155,6 +1165,7 @@ static int kill_something_info(int sig, struct 
siginfo *info, int pid)
  		}
  		ret = count ? retval : -ESRCH;
  	}
+out:
  	read_unlock(&tasklist_lock);

  	return ret;
-- 
1.5.5.1

             reply	other threads:[~2008-07-17 14:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-17 14:56 Daniel Hokka Zakrisson [this message]
     [not found] ` <487F5DA1.6000107-nym3zxDgnZcAvxtiuMwx3w@public.gmane.org>
2008-07-17 17:55   ` [PATCH 2/2] signals: replace p->pid == 1 check with a check for task_child_reaper Eric W. Biederman
     [not found] ` <m14p6ov1j0.fsf@frodo.ebiederm.org>
     [not found]   ` <m14p6ov1j0.fsf-B27657KtZYmhTnVgQlOflh2eb7JE58TQ@public.gmane.org>
2008-07-17 18:21     ` Daniel Hokka Zakrisson
     [not found]   ` <49797.192.168.102.6.1216318897.squirrel@intranet>
2008-07-17 18:51     ` Eric W. Biederman

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=487F5DA1.6000107@hozac.com \
    --to=daniel-nym3zxdgnzcavxtiumwx3w@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=oleg-6lXkIZvqkOAvJsYlp49lxw@public.gmane.org \
    --cc=xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org \
    /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