aboutsummaryrefslogtreecommitdiffstats
path: root/net/sysctl_net.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sysctl_net.c')
-rw-r--r--net/sysctl_net.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/net/sysctl_net.c b/net/sysctl_net.c
index 007c1a6708ee..cefbc367d8be 100644
--- a/net/sysctl_net.c
+++ b/net/sysctl_net.c
@@ -29,23 +29,35 @@
29#include <linux/if_tr.h> 29#include <linux/if_tr.h>
30#endif 30#endif
31 31
32static struct list_head * 32static struct ctl_table_set *
33net_ctl_header_lookup(struct ctl_table_root *root, struct nsproxy *namespaces) 33net_ctl_header_lookup(struct ctl_table_root *root, struct nsproxy *namespaces)
34{ 34{
35 return &namespaces->net_ns->sysctl_table_headers; 35 return &namespaces->net_ns->sysctls;
36} 36}
37 37
38static struct ctl_table_root net_sysctl_root = { 38static int is_seen(struct ctl_table_set *set)
39 .lookup = net_ctl_header_lookup, 39{
40}; 40 return &current->nsproxy->net_ns->sysctls == set;
41}
41 42
42static LIST_HEAD(net_sysctl_ro_tables); 43/* Return standard mode bits for table entry. */
43static struct list_head *net_ctl_ro_header_lookup(struct ctl_table_root *root, 44static int net_ctl_permissions(struct ctl_table_root *root,
44 struct nsproxy *namespaces) 45 struct nsproxy *nsproxy,
46 struct ctl_table *table)
45{ 47{
46 return &net_sysctl_ro_tables; 48 /* Allow network administrator to have same access as root. */
49 if (capable(CAP_NET_ADMIN)) {
50 int mode = (table->mode >> 6) & 7;
51 return (mode << 6) | (mode << 3) | mode;
52 }
53 return table->mode;
47} 54}
48 55
56static struct ctl_table_root net_sysctl_root = {
57 .lookup = net_ctl_header_lookup,
58 .permissions = net_ctl_permissions,
59};
60
49static int net_ctl_ro_header_perms(struct ctl_table_root *root, 61static int net_ctl_ro_header_perms(struct ctl_table_root *root,
50 struct nsproxy *namespaces, struct ctl_table *table) 62 struct nsproxy *namespaces, struct ctl_table *table)
51{ 63{
@@ -56,19 +68,18 @@ static int net_ctl_ro_header_perms(struct ctl_table_root *root,
56} 68}
57 69
58static struct ctl_table_root net_sysctl_ro_root = { 70static struct ctl_table_root net_sysctl_ro_root = {
59 .lookup = net_ctl_ro_header_lookup,
60 .permissions = net_ctl_ro_header_perms, 71 .permissions = net_ctl_ro_header_perms,
61}; 72};
62 73
63static int sysctl_net_init(struct net *net) 74static int sysctl_net_init(struct net *net)
64{ 75{
65 INIT_LIST_HEAD(&net->sysctl_table_headers); 76 setup_sysctl_set(&net->sysctls, NULL, is_seen);
66 return 0; 77 return 0;
67} 78}
68 79
69static void sysctl_net_exit(struct net *net) 80static void sysctl_net_exit(struct net *net)
70{ 81{
71 WARN_ON(!list_empty(&net->sysctl_table_headers)); 82 WARN_ON(!list_empty(&net->sysctls.list));
72 return; 83 return;
73} 84}
74 85
@@ -84,6 +95,7 @@ static __init int sysctl_init(void)
84 if (ret) 95 if (ret)
85 goto out; 96 goto out;
86 register_sysctl_root(&net_sysctl_root); 97 register_sysctl_root(&net_sysctl_root);
98 setup_sysctl_set(&net_sysctl_ro_root.default_set, NULL, NULL);
87 register_sysctl_root(&net_sysctl_ro_root); 99 register_sysctl_root(&net_sysctl_ro_root);
88out: 100out:
89 return ret; 101 return ret;