From: ebiederm@xmission.com (Eric W. Biederman)
To: Oleg Nesterov <oleg@redhat.com>
Cc: "Konstantin Khlebnikov" <khlebnikov@yandex-team.ru>,
linux-api@vger.kernel.org, containers@lists.linux-foundation.org,
linux-kernel@vger.kernel.org,
"Roman Gushchin" <klamm@yandex-team.ru>,
"Serge Hallyn" <serge.hallyn@ubuntu.com>,
"Chen Fan" <chen.fan.fnst@cn.fujitsu.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
"Stéphane Graber" <stgraber@ubuntu.com>
Subject: Re: [PATCH 0/1] ns: introduce proc_get_ns_by_fd()
Date: Tue, 29 Sep 2015 14:05:42 -0500 [thread overview]
Message-ID: <87si5xxczd.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <20150929183833.GA21875@redhat.com> (Oleg Nesterov's message of "Tue, 29 Sep 2015 20:38:33 +0200")
Oleg Nesterov <oleg@redhat.com> writes:
> On 09/29, Eric W. Biederman wrote:
>>
>> Oleg Nesterov <oleg@redhat.com> writes:
>>
>> > OK, I won't insist, this too looks better to me than proc_ns_fdget(&fd_ref).
>> >
>> > And in any case fcheck_files() makes more sense than fdget(), somehow I did
>> > not think about this when I sent 1/1.
>> >
>> > Hmm. and after the quick look at cleanup_net() I can't understand whether
>> > get_net_ns_by_fd() can use ns_by_fd_rcu() + maybe_get_net(to_net_ns()) or
>> > not... Can it?
>>
>> Some of those places need a reference that allows them to sleep, and the
>> code is shared with the legacy pid case so with an addition of get_net
>> we can use ns_by_fd_rcu(). There are cases like setns that could
>> use ns_by_fd_rcu() with code reording.
>>
>> We can implement get_net_ns_by_fd as:
>> struct net *get_net_ns_by_fd(int fd)
>> {
>> struct net *net;
>>
>> rcu_read_lock();
>> net = net_ns_by_fd_rcu(fd);
>> if (!IS_ERR(net))
>> get_net(net);
>> rcu_read_unlock();
>>
>> return net;
>> }
>>
>> Which means we can achieve code sharing with the pure rcu version
>> as a base.
>
> Yes, this is what I meant... but don't we need maybe_get_net() ?
Let me see.
The call chain is a little interesting so let's trace it.
thread1 thread2
net = net_ns_by_fd_rcu(fd); fput(file)
get_net(net); ____fput
__fput
dput
dentry_kill
__dentry_kill
dentry_iput
iput
iput_final
evict
->evict_inode (nsfs_evict)
netns_put
put_net
__put_net
queue_work(net_cleanup_work)
...
cleanup_net
synchronize_rcu.
Given that someone in another thread can put the file descriptor and I
don't see anything explicitly waiting until after the rcu critical
section ends to put the network namespace I guess we do need
maybe_get_net.
In practice I think the delay logic in fput will act as an rcu barrier,
but that is not guaranteed so we had better not count on it. Sigh.
Anyway this is a long ways from a syscall to translate pids.
Eric
next prev parent reply other threads:[~2015-09-29 19:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-25 13:52 [PATCH RFC v3 1/2] nsfs: replace proc_ns_fget() with proc_ns_fdget() Konstantin Khlebnikov
2015-09-25 13:52 ` [PATCH RFC v3 2/2] pidns: introduce syscall getvpid Konstantin Khlebnikov
2015-09-28 4:12 ` kbuild test robot
2015-09-28 16:22 ` Eric W. Biederman
2015-09-28 16:57 ` Eric W. Biederman
2015-10-20 10:04 ` Konstantin Khlebnikov
2015-09-25 17:56 ` [PATCH 0/1] ns: introduce proc_get_ns_by_fd() Oleg Nesterov
2015-09-25 17:57 ` [PATCH 1/1] " Oleg Nesterov
2015-09-28 8:21 ` [PATCH 0/1] " Konstantin Khlebnikov
2015-09-28 16:37 ` Eric W. Biederman
2015-09-29 16:43 ` Oleg Nesterov
2015-09-29 17:30 ` Eric W. Biederman
2015-09-29 18:38 ` Oleg Nesterov
2015-09-29 19:05 ` Eric W. Biederman [this message]
2015-09-30 2:54 ` Chen Fan
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=87si5xxczd.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=klamm@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=stgraber@ubuntu.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