diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-11-15 22:02:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-18 20:30:55 -0500 |
commit | 464dc801c76aa0db88e16e8f5f47c6879858b9b2 (patch) | |
tree | cfaf0f43f4ce50669f07031ec42062b4c9a7f985 /net/ipv6 | |
parent | 73f7ef435934e952c1d70d83d69921ea5d1f6bd4 (diff) |
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/ipv6')
-rw-r--r-- | net/ipv6/addrconf.c | 4 | ||||
-rw-r--r-- | net/ipv6/icmp.c | 7 | ||||
-rw-r--r-- | net/ipv6/reassembly.c | 4 | ||||
-rw-r--r-- | net/ipv6/route.c | 4 | ||||
-rw-r--r-- | net/ipv6/sysctl_net_ipv6.c | 4 |
5 files changed, 22 insertions, 1 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index cb803b7bb0d8..b24b4de5cd26 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -4735,6 +4735,10 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name, | |||
4735 | t->addrconf_vars[i].extra2 = net; | 4735 | t->addrconf_vars[i].extra2 = net; |
4736 | } | 4736 | } |
4737 | 4737 | ||
4738 | /* Don't export sysctls to unprivileged users */ | ||
4739 | if (net->user_ns != &init_user_ns) | ||
4740 | t->addrconf_vars[0].procname = NULL; | ||
4741 | |||
4738 | snprintf(path, sizeof(path), "net/ipv6/conf/%s", dev_name); | 4742 | snprintf(path, sizeof(path), "net/ipv6/conf/%s", dev_name); |
4739 | 4743 | ||
4740 | t->sysctl_header = register_net_sysctl(net, path, t->addrconf_vars); | 4744 | t->sysctl_header = register_net_sysctl(net, path, t->addrconf_vars); |
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index b4a9fd51dae7..d77dc1e2a42b 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c | |||
@@ -967,9 +967,14 @@ struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net) | |||
967 | sizeof(ipv6_icmp_table_template), | 967 | sizeof(ipv6_icmp_table_template), |
968 | GFP_KERNEL); | 968 | GFP_KERNEL); |
969 | 969 | ||
970 | if (table) | 970 | if (table) { |
971 | table[0].data = &net->ipv6.sysctl.icmpv6_time; | 971 | table[0].data = &net->ipv6.sysctl.icmpv6_time; |
972 | 972 | ||
973 | /* Don't export sysctls to unprivileged users */ | ||
974 | if (net->user_ns != &init_user_ns) | ||
975 | table[0].procname = NULL; | ||
976 | } | ||
977 | |||
973 | return table; | 978 | return table; |
974 | } | 979 | } |
975 | #endif | 980 | #endif |
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index da8a4e301b1b..e5253ec9e0fc 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
@@ -616,6 +616,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net) | |||
616 | table[0].data = &net->ipv6.frags.high_thresh; | 616 | table[0].data = &net->ipv6.frags.high_thresh; |
617 | table[1].data = &net->ipv6.frags.low_thresh; | 617 | table[1].data = &net->ipv6.frags.low_thresh; |
618 | table[2].data = &net->ipv6.frags.timeout; | 618 | table[2].data = &net->ipv6.frags.timeout; |
619 | |||
620 | /* Don't export sysctls to unprivileged users */ | ||
621 | if (net->user_ns != &init_user_ns) | ||
622 | table[0].procname = NULL; | ||
619 | } | 623 | } |
620 | 624 | ||
621 | hdr = register_net_sysctl(net, "net/ipv6", table); | 625 | hdr = register_net_sysctl(net, "net/ipv6", table); |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 11249d211ea9..021a48e8a5e2 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -2989,6 +2989,10 @@ struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net) | |||
2989 | table[7].data = &net->ipv6.sysctl.ip6_rt_mtu_expires; | 2989 | table[7].data = &net->ipv6.sysctl.ip6_rt_mtu_expires; |
2990 | table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss; | 2990 | table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss; |
2991 | table[9].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval; | 2991 | table[9].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval; |
2992 | |||
2993 | /* Don't export sysctls to unprivileged users */ | ||
2994 | if (net->user_ns != &init_user_ns) | ||
2995 | table[0].procname = NULL; | ||
2992 | } | 2996 | } |
2993 | 2997 | ||
2994 | return table; | 2998 | return table; |
diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c index e85c48bd404f..b06fd078e6c7 100644 --- a/net/ipv6/sysctl_net_ipv6.c +++ b/net/ipv6/sysctl_net_ipv6.c | |||
@@ -52,6 +52,10 @@ static int __net_init ipv6_sysctl_net_init(struct net *net) | |||
52 | goto out; | 52 | goto out; |
53 | ipv6_table[0].data = &net->ipv6.sysctl.bindv6only; | 53 | ipv6_table[0].data = &net->ipv6.sysctl.bindv6only; |
54 | 54 | ||
55 | /* Don't export sysctls to unprivileged users */ | ||
56 | if (net->user_ns != &init_user_ns) | ||
57 | ipv6_table[0].procname = NULL; | ||
58 | |||
55 | ipv6_route_table = ipv6_route_sysctl_init(net); | 59 | ipv6_route_table = ipv6_route_sysctl_init(net); |
56 | if (!ipv6_route_table) | 60 | if (!ipv6_route_table) |
57 | goto out_ipv6_table; | 61 | goto out_ipv6_table; |