]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
netns: do not call pernet ops for not yet set up init_net namespace
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 10 Aug 2016 21:36:00 +0000 (14:36 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 15 Aug 2016 04:07:20 +0000 (21:07 -0700)
commitf8c46cb39079b7415ada1affc4631ae761d8b621
tree46e8ff39629914fe2d4d64f0c4cf0ff63790aa74
parentd16d9d2ad778e8247617c10703dfd749c776f242
netns: do not call pernet ops for not yet set up init_net namespace

When CONFIG_NET_NS is disabled, registering pernet operations causes
init() to be called immediately with init_net as an argument. Unfortunately
this leads to some pernet ops, such as proc_net_ns_init() to be called too
early, when init_net namespace has not been fully initialized. This causes
issues when we want to change pernet ops to use more data from the net
namespace in question, for example reference user namespace that owns our
network namespace.

To fix this we could either play game of musical chairs and rearrange init
order, or we could do the same as when CONFIG_NET_NS is enabled, and
postpone calling pernet ops->init() until namespace is set up properly.

Note that we can not simply undo commit ed160e839d2e ("[NET]: Cleanup
pernet operation without CONFIG_NET_NS") and use the same implementations
for __register_pernet_operations() and __unregister_pernet_operations(),
because many pernet ops are marked as __net_initdata and will be discarded,
which wreaks havoc on our ops lists. Here we rely on the fact that we only
use lists until init_net is fully initialized, which happens much earlier
than discarding __net_initdata sections.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/net_namespace.c