From: Nagarathnam Muthusamy <nagarathnam.muthusamy@oracle.com> To: Oleg Nesterov <oleg@redhat.com>, Konstantin Khlebnikov <khlebnikov@yandex-team.ru> Cc: linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>, Serge Hallyn <serge.hallyn@ubuntu.com>, "Eric W. Biederman" <ebiederm@xmission.com>, Eugene Syromiatnikov <esyr@redhat.com> Subject: Re: [PATCH v4] pidns: introduce syscall translate_pid Date: Mon, 16 Oct 2017 14:05:05 -0700 [thread overview] Message-ID: <6bba1416-746c-0636-9c6d-d2c9d8934dc6@oracle.com> (raw) In-Reply-To: <20171016162436.GB4142@redhat.com> On 10/16/2017 09:24 AM, Oleg Nesterov wrote: > On 10/13, Konstantin Khlebnikov wrote: >> >> On 13.10.2017 19:05, Oleg Nesterov wrote: >>> I won't insist, but this suggests we should add a new helper, >>> get_ns_by_fd_type(fd, type), and convert get_net_ns_by_fd() to use it >>> as well. >> That was in v3. >> >> I'll prefer to this later, separately. And replace fget with fdget which >> allows to do this without atomic operations if task is single-threaded. > OK, agreed, > >>> Stupid question. Can't we make a simpler API which doesn't need /proc/ ? >>> I mean, >>> >>> sys_translate_pid(pid_t pid, pid_t source_pid, pid_t target_pid) >>> { >>> struct pid_namespace *source_ns, *target_ns; >>> >>> source_ns = task_active_pid_ns(find_task_by_vpid(source_pid)); >>> target_ns = task_active_pid_ns(find_task_by_vpid(target_pid)); >>> >>> ... >>> } >>>> Yes, this is more limited... Do you have a use-case when this is not enough? >> That was in v1 but considered too racy. > Hmm, I don't understand... > > Yes sure, this is racy but open("/proc/$pid/ns/pid") is racy too? > > OK, once you do fd=open("/proc/$pid/ns/pid") you can use this fd even after > its owner exits, while find_task_by_vpid() will fail or find another task if > this pid was already reused. > > But once again, do you have a use-case when this is important? I believe that in V1 Eric pointed out that pid in general is not a clean way to represent namespace. (https://lkml.org/lkml/2015/9/22/1087) Few old interfaces used pid only because at that time there was no better way to represent namespaces. > >> But we could merge both ways: >> >> source >= 0 - pidns fs >> source < 0 - task_pid = -source > But for what? I must have missed something... > > Oleg. >
WARNING: multiple messages have this Message-ID (diff)
From: Nagarathnam Muthusamy <nagarathnam.muthusamy-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> To: Oleg Nesterov <oleg-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>, Konstantin Khlebnikov <khlebnikov-XoJtRXgx1JseBXzfvpsJ4g@public.gmane.org> Cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>, Serge Hallyn <serge.hallyn-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>, "Eric W. Biederman" <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>, Eugene Syromiatnikov <esyr-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Subject: Re: [PATCH v4] pidns: introduce syscall translate_pid Date: Mon, 16 Oct 2017 14:05:05 -0700 [thread overview] Message-ID: <6bba1416-746c-0636-9c6d-d2c9d8934dc6@oracle.com> (raw) In-Reply-To: <20171016162436.GB4142-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> On 10/16/2017 09:24 AM, Oleg Nesterov wrote: > On 10/13, Konstantin Khlebnikov wrote: >> >> On 13.10.2017 19:05, Oleg Nesterov wrote: >>> I won't insist, but this suggests we should add a new helper, >>> get_ns_by_fd_type(fd, type), and convert get_net_ns_by_fd() to use it >>> as well. >> That was in v3. >> >> I'll prefer to this later, separately. And replace fget with fdget which >> allows to do this without atomic operations if task is single-threaded. > OK, agreed, > >>> Stupid question. Can't we make a simpler API which doesn't need /proc/ ? >>> I mean, >>> >>> sys_translate_pid(pid_t pid, pid_t source_pid, pid_t target_pid) >>> { >>> struct pid_namespace *source_ns, *target_ns; >>> >>> source_ns = task_active_pid_ns(find_task_by_vpid(source_pid)); >>> target_ns = task_active_pid_ns(find_task_by_vpid(target_pid)); >>> >>> ... >>> } >>>> Yes, this is more limited... Do you have a use-case when this is not enough? >> That was in v1 but considered too racy. > Hmm, I don't understand... > > Yes sure, this is racy but open("/proc/$pid/ns/pid") is racy too? > > OK, once you do fd=open("/proc/$pid/ns/pid") you can use this fd even after > its owner exits, while find_task_by_vpid() will fail or find another task if > this pid was already reused. > > But once again, do you have a use-case when this is important? I believe that in V1 Eric pointed out that pid in general is not a clean way to represent namespace. (https://lkml.org/lkml/2015/9/22/1087) Few old interfaces used pid only because at that time there was no better way to represent namespaces. > >> But we could merge both ways: >> >> source >= 0 - pidns fs >> source < 0 - task_pid = -source > But for what? I must have missed something... > > Oleg. >
next prev parent reply other threads:[~2017-10-16 21:08 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-10-13 9:26 [PATCH v4] pidns: introduce syscall translate_pid Konstantin Khlebnikov 2017-10-13 9:28 ` Konstantin Khlebnikov 2017-10-13 16:05 ` Oleg Nesterov 2017-10-13 16:13 ` Konstantin Khlebnikov 2017-10-14 8:17 ` Konstantin Khlebnikov 2017-10-14 8:17 ` Konstantin Khlebnikov 2017-10-16 21:36 ` Andrew Morton 2017-10-16 21:36 ` Andrew Morton 2017-10-16 22:07 ` Nagarathnam Muthusamy 2017-10-16 22:07 ` Nagarathnam Muthusamy 2017-10-16 22:54 ` prakash.sangappa 2017-10-17 0:52 ` Andy Lutomirski 2017-10-17 0:52 ` Andy Lutomirski 2017-10-17 15:38 ` Prakash Sangappa 2017-10-17 22:02 ` Andy Lutomirski 2017-10-17 22:02 ` Andy Lutomirski 2017-10-17 22:35 ` prakash sangappa 2017-10-17 22:35 ` prakash sangappa 2017-10-17 22:40 ` Andy Lutomirski 2017-10-17 22:40 ` Andy Lutomirski 2017-10-17 22:53 ` prakash sangappa 2017-10-17 22:53 ` prakash sangappa 2017-11-01 16:59 ` nagarathnam muthusamy 2017-11-01 17:43 ` Jann Horn 2017-11-02 0:38 ` prakash.sangappa 2017-10-16 16:24 ` Oleg Nesterov 2017-10-16 16:24 ` Oleg Nesterov 2017-10-16 21:05 ` Nagarathnam Muthusamy [this message] 2017-10-16 21:05 ` Nagarathnam Muthusamy 2017-10-17 7:41 ` Konstantin Khlebnikov
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=6bba1416-746c-0636-9c6d-d2c9d8934dc6@oracle.com \ --to=nagarathnam.muthusamy@oracle.com \ --cc=akpm@linux-foundation.org \ --cc=ebiederm@xmission.com \ --cc=esyr@redhat.com \ --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 \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.