diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-11-16 03:02:59 (GMT) |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-19 01:30:55 (GMT) |
commit | 464dc801c76aa0db88e16e8f5f47c6879858b9b2 (patch) | |
tree | cfaf0f43f4ce50669f07031ec42062b4c9a7f985 /net/core | |
parent | 73f7ef435934e952c1d70d83d69921ea5d1f6bd4 (diff) | |
download | linux-464dc801c76aa0db88e16e8f5f47c6879858b9b2.tar.xz |
net: Don't export sysctls to unprivileged users
In preparation for supporting the creation of network namespaces
by unprivileged users, modify all of the per net sysctl exports
and refuse to allow them to unprivileged users.
This makes it safe for unprivileged users in general to access
per net sysctls, and allows sysctls to be exported to unprivileged
users on an individual basis as they are deemed safe.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/neighbour.c | 4 | ||||
-rw-r--r-- | net/core/sysctl_net_core.c | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 2257148..f1c0c2e 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -2987,6 +2987,10 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, t->neigh_vars[NEIGH_VAR_BASE_REACHABLE_TIME_MS].extra1 = dev; } + /* Don't export sysctls to unprivileged users */ + if (neigh_parms_net(p)->user_ns != &init_user_ns) + t->neigh_vars[0].procname = NULL; + snprintf(neigh_path, sizeof(neigh_path), "net/%s/neigh/%s", p_name, dev_name_source); t->sysctl_header = diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index a7c3684..d1b0804 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -216,6 +216,11 @@ static __net_init int sysctl_core_net_init(struct net *net) goto err_dup; tbl[0].data = &net->core.sysctl_somaxconn; + + /* Don't export any sysctls to unprivileged users */ + if (net->user_ns != &init_user_ns) { + tbl[0].procname = NULL; + } } net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl); |