From: ebiederm@xmission.com (Eric W. Biederman)
To: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Cc: "Serge E. Hallyn" <serge@hallyn.com>,
Chen Fan <chen.fan.fnst@cn.fujitsu.com>,
linux-api@vger.kernel.org, containers@lists.linux-foundation.org,
Serge Hallyn <serge.hallyn@ubuntu.com>,
Oleg Nesterov <oleg@redhat.com>,
linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH RFC] pidns: introduce syscall getvpid
Date: Tue, 22 Sep 2015 16:00:23 -0500 [thread overview]
Message-ID: <87eghqcgpk.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <56010680.7000301@yandex-team.ru> (Konstantin Khlebnikov's message of "Tue, 22 Sep 2015 10:42:56 +0300")
Konstantin Khlebnikov <khlebnikov@yandex-team.ru> writes:
> On 21.09.2015 17:22, Serge E. Hallyn wrote:
>>
>> So please implement it, as Eric suggested, using the ns inode fds
>> instead of racy pid_t hints for namespaces.
>>
>
> I don't want to loose simple way to use it.
> Sometimes caller cannot prevent races (task its child or
> locked with with ptrace) or it don't care about them.
>
> What about this design:
>
> pid_t getvpid(pid_t pid, pid_t source, pid_t target)
>
> pid > 0 - get vpid of task
> pid = 0 - current pid (= just for symmetry =)
> pid < 0 - get vpid of parent task (ppid of -pid)
> [ that's really useful for poking isolated pidns ]
> source/target > 0 - pid of source/target task
> source/target = 0 - use current as source/target
> source/target < 0 - use pidns fd (1-arg) as source/target
>
> or the same but without =0 sugar:
>
> pid > 0 - get vpid of task
> pid < 0 - get vpid of parent task (ppid of -arg)
> source/target > 0 - pid of source/target task
> source/target <= 0 - use pidns fd (-arg) as source/target
>
> libc caches current pid, extra getpid shouldn't be a problem.
Yuck. An invalid fd like for saying use the current pid namespace is
fine.
Using pids to identify namespaces yuck just yuck. That just seems to
add complexity for no gain except to make programs buggier.
We have a couple of old interfaces that use pids because pids were the
the best we had, but at this point I don't see anything at all that
even suggests that pids are a good choice for identifying namespaces.
If performance is important than caching file descriptors should be
trivial. If performance is not important it should not be hard to
open "/proc/<pid>/ns/pid".
I do not see the gain of using pids in this interface except to confuse
people, and make the interface brittle.
Eric
prev parent reply other threads:[~2015-09-22 21:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-15 12:09 Konstantin Khlebnikov
2015-09-15 14:20 ` Oleg Nesterov
2015-09-15 14:27 ` Eric W. Biederman
2015-09-15 15:01 ` Konstantin Khlebnikov
2015-09-15 15:17 ` Stéphane Graber
2015-09-15 15:51 ` Konstantin Khlebnikov
2015-09-15 17:41 ` Serge Hallyn
2015-09-16 7:37 ` Konstantin Khlebnikov
2015-09-16 14:39 ` Serge E. Hallyn
2015-09-16 14:49 ` Eric W. Biederman
2015-09-16 16:31 ` Serge E. Hallyn
2015-09-21 2:49 ` Chen Fan
2015-09-21 14:22 ` Serge E. Hallyn
2015-09-22 7:42 ` Konstantin Khlebnikov
2015-09-22 21:00 ` Eric W. Biederman [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=87eghqcgpk.fsf@x220.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=akpm@linux-foundation.org \
--cc=chen.fan.fnst@cn.fujitsu.com \
--cc=containers@lists.linux-foundation.org \
--cc=khlebnikov@yandex-team.ru \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=serge.hallyn@ubuntu.com \
--cc=serge@hallyn.com \
--cc=torvalds@linux-foundation.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
Powered by JetHome