public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: ebiederm@xmission•com (Eric W. Biederman)
To: Nathan Lynch <ntl@pobox•com>
Cc: linux-arch@vger•kernel.org, linux-kernel@vger•kernel.org,
	netdev@vger•kernel.org, linux-fsdevel@vger•kernel.org,
	jamal <hadi@cyberus•ca>, Daniel Lezcano <daniel.lezcano@free•fr>,
	Linux Containers <containers@lists•osdl.org>,
	Renato Westphal <renatowestphal@gmail•com>
Subject: Re: [PATCH 3/7] ns proc: Add support for the network namespace.
Date: Wed, 11 May 2011 14:34:37 -0700	[thread overview]
Message-ID: <m139kkncpe.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <1305141705.1236.49.camel@orca.stoopid.dyndns.org> (Nathan Lynch's message of "Wed, 11 May 2011 14:21:34 -0500")

Nathan Lynch <ntl@pobox•com> writes:

> On Fri, 2011-05-06 at 19:24 -0700, Eric W. Biederman wrote:
>> diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
>> index 3f86026..bf7707e 100644
>> --- a/net/core/net_namespace.c
>> +++ b/net/core/net_namespace.c
>> @@ -573,3 +573,34 @@ void unregister_pernet_device(struct pernet_operations *ops)
>>  	mutex_unlock(&net_mutex);
>>  }
>>  EXPORT_SYMBOL_GPL(unregister_pernet_device);
>> +
>> +#ifdef CONFIG_NET_NS
>> +static void *netns_get(struct task_struct *task)
>> +{
>> +	struct net *net;
>> +	rcu_read_lock();
>> +	net = get_net(task->nsproxy->net_ns);
>
> This should use task_nsproxy() and check the result before grabbing the
> net_ns, but I think you fix that in a later patch.
>
> Regardless, it looks as if all the proc_ns_ops->get() implementations
> really just want the nsproxy, so maybe the get() methods should take
> that instead of the task_struct, and proc_ns_instantiate() should do
> something like:
>
> struct nsproxy *nsproxy;
> ...
>
> ei->ns_ops = ns_ops;
> error = -ESRCH;
> rcu_read_lock();
> nsproxy = task_nsproxy(task);
> rcu_read_unlock();
> if (!nsproxy)
> 	got out;
> ei->ns = ns_ops->get(nsproxy);
>
>
> So then the zombie check is consolidated in one place instead of having
> to do it in every get() method.

For the pid namespace at least I want the task not the nsproxy,
so I can use task_active_pid_namespace().

I admit that is a little asymmetrical with the install, but at
least until the details of getting the pid namespace working in
this context are worked out I don't want to reconsider the
current design.

There is also the user namespace that does not even exist in
nsproxy to consider.  I will worry about that namespace when
it happens.

Ultimately nsproxy is an space/time optimization that not all
namespaces use so forcing it in the design is probably not
what we want.

>> +	rcu_read_unlock();
>> +	return net;
>> +}
>> +
>> +static void netns_put(void *ns)
>> +{
>> +	put_net(ns);
>> +}
>> +
>> +static int netns_install(struct nsproxy *nsproxy, void *ns)
>> +{
>> +	put_net(nsproxy->net_ns);
>> +	nsproxy->net_ns = get_net(ns);
>> +	return 0;
>> +}
>
> This introduces a window where, potentially, nsproxy->net_ns is stale
> before it is updated with the namespace which is being attached, no? 
> (Same concern applies to other install methods in the patch set).  It
> seems possible to oops the kernel in this window by looking up
> /proc/$PID/ns/net while $PID is in the midst of setns().

Except the nsproxy being referred to is a brand new nsproxy, with an
extra reference count on every namespace.  current->nsproxy still
contains the reference counts of the current process.

Eric

  reply	other threads:[~2011-05-11 21:34 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-07  2:23 [PATCH 0/7] Network namespace manipulation with file descriptors Eric W. Biederman
2011-05-07  2:24 ` [PATCH 1/7] ns: proc files for namespace naming policy Eric W. Biederman
     [not found]   ` <1304735101-1824-1-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2011-05-07  2:24     ` [PATCH 2/7] ns: Introduce the setns syscall Eric W. Biederman
     [not found]       ` <1304735101-1824-2-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2011-05-07  8:01         ` Rémi Denis-Courmont
2011-05-07 13:57           ` Eric W. Biederman
2011-05-07 22:39       ` Daniel Lezcano
2011-05-08  3:51       ` Matt Helsley
2011-05-11 19:21       ` Nathan Lynch
2011-05-11 20:33         ` Eric W. Biederman
2011-05-07  2:25     ` [PATCH 6/7] net: Allow setting the network namespace by fd Eric W. Biederman
2011-05-07 22:46       ` Daniel Lezcano
2011-05-07  2:24   ` [PATCH 3/7] ns proc: Add support for the network namespace Eric W. Biederman
2011-05-07 22:41     ` Daniel Lezcano
2011-05-11 19:21     ` Nathan Lynch
2011-05-11 21:34       ` Eric W. Biederman [this message]
2011-05-11 21:42         ` Nathan Lynch
2011-05-07  2:24   ` [PATCH 4/7] ns proc: Add support for the uts namespace Eric W. Biederman
2011-05-07 22:42     ` Daniel Lezcano
2011-05-07  2:24   ` [PATCH 5/7] ns proc: Add support for the ipc namespace Eric W. Biederman
2011-05-07 22:44     ` Daniel Lezcano
2011-05-07  2:25   ` [PATCH 7/7] ns: Wire up the setns system call Eric W. Biederman
2011-05-07  8:27     ` Geert Uytterhoeven
2011-05-07 14:09       ` Eric W. Biederman
2011-05-07 18:22         ` Geert Uytterhoeven
2011-05-07 13:59     ` Mike Frysinger
2011-05-07 20:06     ` James Bottomley
2011-05-08  2:19       ` Eric W. Biederman
2011-05-08  4:02         ` James Bottomley
2011-05-07 22:37   ` [PATCH 1/7] ns: proc files for namespace naming policy Daniel Lezcano
2011-05-11 19:20   ` Nathan Lynch
2011-05-11 22:52     ` Eric W. Biederman
     [not found] ` <m1tyd7p7tq.fsf-+imSwln9KH6u2/kzUuoCbdi2O/JbrIOy@public.gmane.org>
2011-05-07  6:58   ` [PATCH 0/7] Network namespace manipulation with file descriptors Alex Bligh
2011-05-07 14:18     ` Eric W. Biederman
2011-05-08 12:31       ` Alex Bligh
     [not found]       ` <m1fwoqoapn.fsf-+imSwln9KH6u2/kzUuoCbdi2O/JbrIOy@public.gmane.org>
2011-05-17 11:11         ` David Lamparter
2011-05-17 14:33           ` Eric W. Biederman
2011-05-17 15:35             ` David Lamparter
2011-05-22  4:19               ` Renato Westphal
2011-05-09 19:04 ` David Miller
2011-05-09 19:59   ` Eric W. Biederman
2011-05-09 20:40     ` David Miller
2011-05-09 20:54       ` Eric W. Biederman
2011-05-09 20:55         ` David Miller
2011-05-10 21:56       ` Luck, Tony
2011-05-10 23:02 ` Eric W. Biederman
2011-05-18 12:43 ` Identifying network namespaces (was: Network namespace manipulation with file descriptors) David Lamparter
2011-05-18 13:03   ` Alexey Dobriyan
     [not found]     ` <BANLkTikmrC86hk=W84UBwhJLe_uGAN4w9w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-05-18 13:33       ` David Lamparter
2011-05-18 14:13         ` Alexey Dobriyan

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=m139kkncpe.fsf@fess.ebiederm.org \
    --to=ebiederm@xmission$(echo .)com \
    --cc=containers@lists$(echo .)osdl.org \
    --cc=daniel.lezcano@free$(echo .)fr \
    --cc=hadi@cyberus$(echo .)ca \
    --cc=linux-arch@vger$(echo .)kernel.org \
    --cc=linux-fsdevel@vger$(echo .)kernel.org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=ntl@pobox$(echo .)com \
    --cc=renatowestphal@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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