mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Daniel Hokka Zakrisson" <daniel@hozac.com>
To: "Oleg Nesterov" <oleg@tv-sign.ru>
Cc: linux-kernel@vger.kernel.org,
	containers@lists.linux-foundation.org, ebiederm@xmission.com,
	xemul@openvz.org, akpm@linux-foundation.org
Subject: Re: [PATCH 1/2] signals: kill(-1) should only signal processes in  the same namespace
Date: Wed, 23 Jul 2008 18:09:40 +0200 (CEST)	[thread overview]
Message-ID: <57249.192.168.101.12.1216829380.squirrel@intranet> (raw)
In-Reply-To: <20080723143411.GA2905@tv-sign.ru>

Oleg Nesterov wrote:
> On 07/17, Daniel Hokka Zakrisson wrote:
>>
>> +int task_in_pid_ns(struct task_struct *tsk, struct pid_namespace *ns)
>> +{
>> +	struct pid *pid = task_pid(tsk);
>> +
>> +	if (!pid)
>> +		return 0;
>> +
>> +	if (pid->level < ns->level)
>> +		return 0;
>> +
>> +	if (pid->numbers[ns->level].ns != ns)
>> +		return 0;
>> +
>> +	return 1;
>> +}
>> +
>>  static __init int pid_namespaces_init(void)
>>  {
>>  	pid_ns_cachep = KMEM_CACHE(pid_namespace, SLAB_PANIC);
>> diff --git a/kernel/signal.c b/kernel/signal.c
>> index 6c0958e..93713a5 100644
>> --- a/kernel/signal.c
>> +++ b/kernel/signal.c
>> @@ -1145,7 +1145,8 @@ static int kill_something_info(int sig, struct
>> siginfo *info, int pid)
>>  		struct task_struct * p;
>>
>>  		for_each_process(p) {
>> -			if (p->pid > 1 && !same_thread_group(p, current)) {
>> +			if (p->pid > 1 && !same_thread_group(p, current) &&
>> +			    task_in_pid_ns(p, current->nsproxy->pid_ns)) {
>>  				int err = group_send_sig_info(sig, info, p);
>>  				++count;
>>  				if (err != -EPERM)
>
> Do we really need all these complications? Afaics, we can make
> a simpler patch,
>
> 	--- kernel/signal.c
> 	+++ kernel/signal.c
> 	@@ -1136,7 +1136,7 @@ static int kill_something_info(int sig,
> 			struct task_struct * p;
>
> 			for_each_process(p) {
> 	-			if (p->pid > 1 && !same_thread_group(p, current)) {
> 	+			if (task_pid_vnr(p) > 1 && !same_thread_group(p, current)) {
> 					int err = group_send_sig_info(sig, info, p);
> 					++count;
> 					if (err != -EPERM)
>
>
> task_pid_vnr(p) returns 0 if "p" is not visible from the current's
> namespace. "> 1" ensures we don't kill the child reaper as well.
>
> No?
>
> Oleg.

You are absolutely right, that is sufficient and much cleaner.

-- 
Daniel Hokka Zakrisson

      reply	other threads:[~2008-07-23 16:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-17 14:55 Daniel Hokka Zakrisson
2008-07-17 15:01 ` Pavel Emelyanov
2008-07-17 15:24   ` Daniel Hokka Zakrisson
2008-07-17 15:54     ` Pavel Emelyanov
2008-07-17 17:32       ` Oleg Nesterov
2008-07-17 17:50         ` Eric W. Biederman
2008-07-17 17:45     ` Eric W. Biederman
2008-07-17 18:39       ` Daniel Hokka Zakrisson
2008-07-17 18:45         ` Eric W. Biederman
2008-07-17 18:13 ` sukadev
2008-07-17 18:44   ` Daniel Hokka Zakrisson
2008-07-17 18:46   ` Eric W. Biederman
2008-07-23 14:34 ` Oleg Nesterov
2008-07-23 16:09   ` Daniel Hokka Zakrisson [this message]

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=57249.192.168.101.12.1216829380.squirrel@intranet \
    --to=daniel@hozac.com \
    --cc=akpm@linux-foundation.org \
    --cc=containers@lists.linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@tv-sign.ru \
    --cc=xemul@openvz.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

all inboxes | Powered by JetHome®