Skip to contentSkip to conversation

sysctl: make the sys.net.core sysctls per-namespace

PATCH Applied Pavel Emelyanov 2 participants 2 messages Dec 7, 2007 – Dec 8, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 sysctl: make the sys.net.core sysctls per-namespace

Making them per-namespace is required for the following two reasons:

First, some ctl values have a per-namespace meaning. Second, making them writable from the sub-namespace is an isolation hole.

So I introduce the pernet operations to create these tables. For init_net I use the existing statically declared tables, for sub-namespace they are duplicated and the write bits are removed from the mode.

---

include/net/net_namespace.h +3 -0
index f97b2a4..d593611 100644
@@ -37,6 +37,9 @@ struct net {
 
 	struct sock 		*rtnl;			/* rtnetlink socket */
 
+	/* core sysctls */
+	struct ctl_table_header	*sysctl_core_hdr;
+
 	/* List of all packet sockets. */
 	rwlock_t		packet_sklist_lock;
 	struct hlist_head	packet_sklist;
net/core/sysctl_net_core.c +45 -5

63 lines not on this page · raw message

Signature · 1 line
1.5.3.4
maintainer
#1 lore raw

From: Pavel Emelyanov <[email protected]>
Date: Fri, 07 Dec 2007 16:07:19 +0300

Quoted 7 lines

Making them per-namespace is required for the following two reasons:

First, some ctl values have a per-namespace meaning. Second, making them writable from the sub-namespace is an isolation hole.

Quoted 6 lines

So I introduce the pernet operations to create these tables. For init_net I use the existing statically declared tables, for sub-namespace they are duplicated and the write bits are removed from the mode.

Applied to net-2.6.25, but I fear you're going to need to do something similar for ipv4, ipv6, and who knows what other protocols. And as a result we'll end up with all kinds of protocol specific things in the net namespace structure which totally stinks.

Such things will need to be registered dynamically just like the protocols themselves are into the kernel.