From: ebiederm@xmission.com (Eric W. Biederman)
To: Dave Hansen <haveblue@us.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
linux-kernel@vger.kernel.org,
Linux Containers <containers@lists.osdl.org>,
Andrew Morton <akpm@linux-foundation.org>,
Oleg Nesterov <oleg@tv-sign.ru>,
Pavel Emelyanov <xemul@openvz.org>,
"Sukadev Bhattiprolu [imap]" <sukadev@us.ibm.com>
Subject: Re: [PATCH] pidns: Limit kill -1 and cap_set_all
Date: Mon, 29 Oct 2007 11:59:48 -0600 [thread overview]
Message-ID: <m1pryxpzsb.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <1193673738.24087.176.camel@localhost> (Dave Hansen's message of "Mon, 29 Oct 2007 09:02:18 -0700")
Dave Hansen <haveblue@us.ibm.com> writes:
> On Fri, 2007-10-26 at 14:37 -0600, Eric W. Biederman wrote:
>>
>> +static int pid_in_pid_ns(struct pid *pid, struct pid_namespace *ns)
>> +{
>> + return pid && (ns->level <= pid->level) &&
>> + pid->numbers[ns->level].ns == ns;
>> +}
>
> Could we blow this out a little bit? (I think the blown-out version
> lends itself to being better commented, and easier to read.) Also, can
> we think of any better name for this? It seems a bit funky that:
>
> pid_in_pid_ns(mypid, &init_pid_ns);
>
> would _ever_ return 0.
It can't.
> So, it isn't truly a test for belonging *in* a
> namespace, but having that namespace be the lowest level one.
No. It is precisely a test for being in a namespace.
We first check ns->level to make certain it doesn't fall out
of the array, and then we check to see if the namespace we
are looking for is at that level.
pid->numbers[0].ns == &init_pid_ns.
> I think
> Suka toyed with calling it an "active" or "primary" pid namespace. That
> differentiated mere membership in a pid namespace from the one that
> actually molds that pid's view of the world.
What we want for the test is a test for membership.
> static int pid_in_pid_ns(struct pid *pid, struct pid_namespace *ns)
> {
> if (!pid)
> return 0;
> if (ns->level > pid->level)
> return 0;
> if (pid->numbers[ns->level].ns != ns)
> return 0;
> return 1;
> }
I don't have a problem with that. The rest of the checks for
this in kernel/pid.c are in the same form.
Eric
next prev parent reply other threads:[~2007-10-29 18:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-26 17:48 [PATCH] proc: Fix proc_kill_inodes to kill dentries on all proc superblocks Eric W. Biederman
2007-10-26 18:06 ` Linus Torvalds
2007-10-26 18:36 ` Eric W. Biederman
2007-10-26 19:43 ` [PATCH] proc: Simplify and correct proc_flush_task Eric W. Biederman
2007-10-26 20:37 ` [PATCH] pidns: Limit kill -1 and cap_set_all Eric W. Biederman
2007-10-29 8:38 ` Kirill Korotaev
2007-10-29 18:07 ` Eric W. Biederman
2007-10-29 16:02 ` Dave Hansen
2007-10-29 17:59 ` Eric W. Biederman [this message]
2007-10-29 18:07 ` Dave Hansen
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=m1pryxpzsb.fsf@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=akpm@linux-foundation.org \
--cc=containers@lists.osdl.org \
--cc=haveblue@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@tv-sign.ru \
--cc=sukadev@us.ibm.com \
--cc=torvalds@linux-foundation.org \
--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