* [PATCH net-next 0/6][NETNS]: Revisit read-only-in-namespaces sysctls.
@ 2008-05-19 15:50 Pavel Emelyanov
2008-05-19 15:52 ` [PATCH net-next 1/6][NETNS]: Introduce sysctl root for read-only net sysctls Pavel Emelyanov
` (5 more replies)
0 siblings, 6 replies; 13+ messages in thread
From: Pavel Emelyanov @ 2008-05-19 15:50 UTC (permalink / raw)
To: David Miller; +Cc: Linux Netdev List
Hope, it's not too early to post to net-next, but the one
looks alive for quite a long time already :)
After sysctl tables permissions are finally (thanks to Andrew)
in mainline I have revisited issue with sysctls, that are to
be read-only in net namespaces.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net-next 1/6][NETNS]: Introduce sysctl root for read-only net sysctls.
2008-05-19 15:50 [PATCH net-next 0/6][NETNS]: Revisit read-only-in-namespaces sysctls Pavel Emelyanov
@ 2008-05-19 15:52 ` Pavel Emelyanov
2008-05-19 20:53 ` David Miller
2008-05-19 15:55 ` [PATCH net-next 2/6][NETNS]: Register net/core/ sysctls at read-only root Pavel Emelyanov
` (4 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Pavel Emelyanov @ 2008-05-19 15:52 UTC (permalink / raw)
To: David Miller; +Cc: Linux Netdev List
This one stores all ctl-heads in one list and restricts the
permissions not give write access to non-init net namespaces.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
include/net/net_namespace.h | 3 +++
net/sysctl_net.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index aa540e6..8df751b 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -201,8 +201,11 @@ extern void unregister_pernet_gen_device(int id, struct pernet_operations *);
struct ctl_path;
struct ctl_table;
struct ctl_table_header;
+
extern struct ctl_table_header *register_net_sysctl_table(struct net *net,
const struct ctl_path *path, struct ctl_table *table);
+extern struct ctl_table_header *register_net_sysctl_rotable(
+ const struct ctl_path *path, struct ctl_table *table);
extern void unregister_net_sysctl_table(struct ctl_table_header *header);
#endif /* __NET_NET_NAMESPACE_H */
diff --git a/net/sysctl_net.c b/net/sysctl_net.c
index b4f0525..d8e7916 100644
--- a/net/sysctl_net.c
+++ b/net/sysctl_net.c
@@ -40,6 +40,27 @@ static struct ctl_table_root net_sysctl_root = {
.lookup = net_ctl_header_lookup,
};
+static LIST_HEAD(net_sysctl_ro_tables);
+static struct list_head *net_ctl_ro_header_lookup(struct ctl_table_root *root,
+ struct nsproxy *namespaces)
+{
+ return &net_sysctl_ro_tables;
+}
+
+static int net_ctl_ro_header_perms(struct ctl_table_root *root,
+ struct nsproxy *namespaces, struct ctl_table *table)
+{
+ if (namespaces->net_ns == &init_net)
+ return table->mode;
+ else
+ return table->mode & ~0222;
+}
+
+static struct ctl_table_root net_sysctl_ro_root = {
+ .lookup = net_ctl_ro_header_lookup,
+ .permissions = net_ctl_ro_header_perms,
+};
+
static int sysctl_net_init(struct net *net)
{
INIT_LIST_HEAD(&net->sysctl_table_headers);
@@ -64,6 +85,7 @@ static __init int sysctl_init(void)
if (ret)
goto out;
register_sysctl_root(&net_sysctl_root);
+ register_sysctl_root(&net_sysctl_ro_root);
out:
return ret;
}
@@ -80,6 +102,14 @@ struct ctl_table_header *register_net_sysctl_table(struct net *net,
}
EXPORT_SYMBOL_GPL(register_net_sysctl_table);
+struct ctl_table_header *register_net_sysctl_rotable(const
+ struct ctl_path *path, struct ctl_table *table)
+{
+ return __register_sysctl_paths(&net_sysctl_ro_root,
+ &init_nsproxy, path, table);
+}
+EXPORT_SYMBOL_GPL(register_net_sysctl_rotable);
+
void unregister_net_sysctl_table(struct ctl_table_header *header)
{
unregister_sysctl_table(header);
--
1.5.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 2/6][NETNS]: Register net/core/ sysctls at read-only root.
2008-05-19 15:50 [PATCH net-next 0/6][NETNS]: Revisit read-only-in-namespaces sysctls Pavel Emelyanov
2008-05-19 15:52 ` [PATCH net-next 1/6][NETNS]: Introduce sysctl root for read-only net sysctls Pavel Emelyanov
@ 2008-05-19 15:55 ` Pavel Emelyanov
2008-05-19 20:53 ` David Miller
2008-05-19 15:58 ` [PATCH net-next 3/6][FRAGS]: Rename sysctl-related functions/variables Pavel Emelyanov
` (3 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Pavel Emelyanov @ 2008-05-19 15:55 UTC (permalink / raw)
To: David Miller; +Cc: Linux Netdev List
Most of the net/core/xxx sysctls are read-only now, but this
goal is achieved with excessive memory consumption in each
namespace - the whole table is cloned and most of the entries
in it are ~= 0222.
Split it into two parts and register (the largest) one at the
read-only root.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/core/sysctl_net_core.c | 39 +++++++++++++++++++--------------------
1 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 5fc8010..a570e2a 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -125,14 +125,6 @@ static struct ctl_table net_core_table[] = {
#endif /* CONFIG_XFRM */
#endif /* CONFIG_NET */
{
- .ctl_name = NET_CORE_SOMAXCONN,
- .procname = "somaxconn",
- .data = &init_net.core.sysctl_somaxconn,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec
- },
- {
.ctl_name = NET_CORE_BUDGET,
.procname = "netdev_budget",
.data = &netdev_budget,
@@ -151,6 +143,18 @@ static struct ctl_table net_core_table[] = {
{ .ctl_name = 0 }
};
+static struct ctl_table netns_core_table[] = {
+ {
+ .ctl_name = NET_CORE_SOMAXCONN,
+ .procname = "somaxconn",
+ .data = &init_net.core.sysctl_somaxconn,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = &proc_dointvec
+ },
+ { .ctl_name = 0 }
+};
+
static __net_initdata struct ctl_path net_core_path[] = {
{ .procname = "net", .ctl_name = CTL_NET, },
{ .procname = "core", .ctl_name = NET_CORE, },
@@ -159,23 +163,17 @@ static __net_initdata struct ctl_path net_core_path[] = {
static __net_init int sysctl_core_net_init(struct net *net)
{
- struct ctl_table *tbl, *tmp;
+ struct ctl_table *tbl;
net->core.sysctl_somaxconn = SOMAXCONN;
- tbl = net_core_table;
+ tbl = netns_core_table;
if (net != &init_net) {
- tbl = kmemdup(tbl, sizeof(net_core_table), GFP_KERNEL);
+ tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
if (tbl == NULL)
goto err_dup;
- for (tmp = tbl; tmp->procname; tmp++) {
- if (tmp->data >= (void *)&init_net &&
- tmp->data < (void *)(&init_net + 1))
- tmp->data += (char *)net - (char *)&init_net;
- else
- tmp->mode &= ~0222;
- }
+ tbl[0].data = &net->core.sysctl_somaxconn;
}
net->core.sysctl_hdr = register_net_sysctl_table(net,
@@ -186,7 +184,7 @@ static __net_init int sysctl_core_net_init(struct net *net)
return 0;
err_reg:
- if (tbl != net_core_table)
+ if (tbl != netns_core_table)
kfree(tbl);
err_dup:
return -ENOMEM;
@@ -198,7 +196,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
tbl = net->core.sysctl_hdr->ctl_table_arg;
unregister_net_sysctl_table(net->core.sysctl_hdr);
- BUG_ON(tbl == net_core_table);
+ BUG_ON(tbl == netns_core_table);
kfree(tbl);
}
@@ -209,6 +207,7 @@ static __net_initdata struct pernet_operations sysctl_core_ops = {
static __init int sysctl_core_init(void)
{
+ register_net_sysctl_rotable(net_core_path, net_core_table);
return register_pernet_subsys(&sysctl_core_ops);
}
--
1.5.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 3/6][FRAGS]: Rename sysctl-related functions/variables.
2008-05-19 15:50 [PATCH net-next 0/6][NETNS]: Revisit read-only-in-namespaces sysctls Pavel Emelyanov
2008-05-19 15:52 ` [PATCH net-next 1/6][NETNS]: Introduce sysctl root for read-only net sysctls Pavel Emelyanov
2008-05-19 15:55 ` [PATCH net-next 2/6][NETNS]: Register net/core/ sysctls at read-only root Pavel Emelyanov
@ 2008-05-19 15:58 ` Pavel Emelyanov
2008-05-19 20:53 ` David Miller
2008-05-19 16:02 ` [PATCH net-next 4/6][IP6FRAGS]: Handle error, returned from register_pernet_subsys Pavel Emelyanov
` (2 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Pavel Emelyanov @ 2008-05-19 15:58 UTC (permalink / raw)
To: David Miller; +Cc: Linux Netdev List
The fragments sysctls also contains some, that are to be
visible, but read-only in net namespaces.
The naming in net/core/sysctl_net_core.c is - tables, that are
to be registered in namespaces have a "ns" word in their names.
So rename ones in ipv4/ip_fragment.c and ipv6/reassembly.c to
fit this.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/ipv4/ip_fragment.c | 18 +++++++++---------
net/ipv6/reassembly.c | 18 +++++++++---------
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index cd6ce6a..7f102ee 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -598,7 +598,7 @@ int ip_defrag(struct sk_buff *skb, u32 user)
#ifdef CONFIG_SYSCTL
static int zero;
-static struct ctl_table ip4_frags_ctl_table[] = {
+static struct ctl_table ip4_frags_ns_ctl_table[] = {
{
.ctl_name = NET_IPV4_IPFRAG_HIGH_THRESH,
.procname = "ipfrag_high_thresh",
@@ -644,14 +644,14 @@ static struct ctl_table ip4_frags_ctl_table[] = {
{ }
};
-static int ip4_frags_ctl_register(struct net *net)
+static int ip4_frags_ns_ctl_register(struct net *net)
{
struct ctl_table *table;
struct ctl_table_header *hdr;
- table = ip4_frags_ctl_table;
+ table = ip4_frags_ns_ctl_table;
if (net != &init_net) {
- table = kmemdup(table, sizeof(ip4_frags_ctl_table), GFP_KERNEL);
+ table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
if (table == NULL)
goto err_alloc;
@@ -676,7 +676,7 @@ err_alloc:
return -ENOMEM;
}
-static void ip4_frags_ctl_unregister(struct net *net)
+static void ip4_frags_ns_ctl_unregister(struct net *net)
{
struct ctl_table *table;
@@ -685,12 +685,12 @@ static void ip4_frags_ctl_unregister(struct net *net)
kfree(table);
}
#else
-static inline int ip4_frags_ctl_register(struct net *net)
+static inline int ip4_frags_ns_ctl_register(struct net *net)
{
return 0;
}
-static inline void ip4_frags_ctl_unregister(struct net *net)
+static inline void ip4_frags_ns_ctl_unregister(struct net *net)
{
}
#endif
@@ -714,12 +714,12 @@ static int ipv4_frags_init_net(struct net *net)
inet_frags_init_net(&net->ipv4.frags);
- return ip4_frags_ctl_register(net);
+ return ip4_frags_ns_ctl_register(net);
}
static void ipv4_frags_exit_net(struct net *net)
{
- ip4_frags_ctl_unregister(net);
+ ip4_frags_ns_ctl_unregister(net);
inet_frags_exit_net(&net->ipv4.frags, &ip4_frags);
}
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 798cabc..7e008de 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -632,7 +632,7 @@ static struct inet6_protocol frag_protocol =
};
#ifdef CONFIG_SYSCTL
-static struct ctl_table ip6_frags_ctl_table[] = {
+static struct ctl_table ip6_frags_ns_ctl_table[] = {
{
.ctl_name = NET_IPV6_IP6FRAG_HIGH_THRESH,
.procname = "ip6frag_high_thresh",
@@ -670,14 +670,14 @@ static struct ctl_table ip6_frags_ctl_table[] = {
{ }
};
-static int ip6_frags_sysctl_register(struct net *net)
+static int ip6_frags_ns_sysctl_register(struct net *net)
{
struct ctl_table *table;
struct ctl_table_header *hdr;
- table = ip6_frags_ctl_table;
+ table = ip6_frags_ns_ctl_table;
if (net != &init_net) {
- table = kmemdup(table, sizeof(ip6_frags_ctl_table), GFP_KERNEL);
+ table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
if (table == NULL)
goto err_alloc;
@@ -701,7 +701,7 @@ err_alloc:
return -ENOMEM;
}
-static void ip6_frags_sysctl_unregister(struct net *net)
+static void ip6_frags_ns_sysctl_unregister(struct net *net)
{
struct ctl_table *table;
@@ -710,12 +710,12 @@ static void ip6_frags_sysctl_unregister(struct net *net)
kfree(table);
}
#else
-static inline int ip6_frags_sysctl_register(struct net *net)
+static inline int ip6_frags_ns_sysctl_register(struct net *net)
{
return 0;
}
-static inline void ip6_frags_sysctl_unregister(struct net *net)
+static inline void ip6_frags_ns_sysctl_unregister(struct net *net)
{
}
#endif
@@ -728,12 +728,12 @@ static int ipv6_frags_init_net(struct net *net)
inet_frags_init_net(&net->ipv6.frags);
- return ip6_frags_sysctl_register(net);
+ return ip6_frags_ns_sysctl_register(net);
}
static void ipv6_frags_exit_net(struct net *net)
{
- ip6_frags_sysctl_unregister(net);
+ ip6_frags_ns_sysctl_unregister(net);
inet_frags_exit_net(&net->ipv6.frags, &ip6_frags);
}
--
1.5.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 4/6][IP6FRAGS]: Handle error, returned from register_pernet_subsys.
2008-05-19 15:50 [PATCH net-next 0/6][NETNS]: Revisit read-only-in-namespaces sysctls Pavel Emelyanov
` (2 preceding siblings ...)
2008-05-19 15:58 ` [PATCH net-next 3/6][FRAGS]: Rename sysctl-related functions/variables Pavel Emelyanov
@ 2008-05-19 16:02 ` Pavel Emelyanov
2008-05-19 20:54 ` David Miller
2008-05-19 16:04 ` [PATCH net-next 5/6][FRAGS]: Register some ctls at read-only root Pavel Emelyanov
2008-05-19 16:06 ` [PATCH net-next 6/6][IPV6]: Register some net/ipv6/ core sysctls " Pavel Emelyanov
5 siblings, 1 reply; 13+ messages in thread
From: Pavel Emelyanov @ 2008-05-19 16:02 UTC (permalink / raw)
To: David Miller; +Cc: Linux Netdev List
The error code is ignored now, but ipv6 is a module and one can
be loaded under memory pressure, so the error may occur (in theory).
Besides, I'm going to handle error returned from registering a
read-only part of the table, so ignoring this one, while handing
the other one would look strange.
(However, this possibility of error is rather small, so I'm not
sure whether this is a candidate for current net tree).
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/ipv6/reassembly.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 7e008de..130d6f6 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -750,7 +750,9 @@ int __init ipv6_frag_init(void)
if (ret)
goto out;
- register_pernet_subsys(&ip6_frags_ops);
+ ret = register_pernet_subsys(&ip6_frags_ops);
+ if (ret)
+ goto err_pernet;
ip6_frags.hashfn = ip6_hashfn;
ip6_frags.constructor = ip6_frag_init;
@@ -763,6 +765,10 @@ int __init ipv6_frag_init(void)
inet_frags_init(&ip6_frags);
out:
return ret;
+
+err_pernet:
+ inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT);
+ goto out;
}
void ipv6_frag_exit(void)
--
1.5.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 5/6][FRAGS]: Register some ctls at read-only root.
2008-05-19 15:50 [PATCH net-next 0/6][NETNS]: Revisit read-only-in-namespaces sysctls Pavel Emelyanov
` (3 preceding siblings ...)
2008-05-19 16:02 ` [PATCH net-next 4/6][IP6FRAGS]: Handle error, returned from register_pernet_subsys Pavel Emelyanov
@ 2008-05-19 16:04 ` Pavel Emelyanov
2008-05-19 20:54 ` David Miller
2008-05-19 16:06 ` [PATCH net-next 6/6][IPV6]: Register some net/ipv6/ core sysctls " Pavel Emelyanov
5 siblings, 1 reply; 13+ messages in thread
From: Pavel Emelyanov @ 2008-05-19 16:04 UTC (permalink / raw)
To: David Miller; +Cc: Linux Netdev List
Parts of fragments-related sysctls are read-only, but this is
done by cloning all the tables and dropping write-bits from
mode. Do the same but with read-only root.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/ipv4/ip_fragment.c | 16 ++++++++++++++--
net/ipv6/reassembly.c | 35 ++++++++++++++++++++++++++++++++++-
2 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 7f102ee..be1cb89 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -624,6 +624,10 @@ static struct ctl_table ip4_frags_ns_ctl_table[] = {
.proc_handler = &proc_dointvec_jiffies,
.strategy = &sysctl_jiffies
},
+ { }
+};
+
+static struct ctl_table ip4_frags_ctl_table[] = {
{
.ctl_name = NET_IPV4_IPFRAG_SECRET_INTERVAL,
.procname = "ipfrag_secret_interval",
@@ -658,8 +662,6 @@ static int ip4_frags_ns_ctl_register(struct net *net)
table[0].data = &net->ipv4.frags.high_thresh;
table[1].data = &net->ipv4.frags.low_thresh;
table[2].data = &net->ipv4.frags.timeout;
- table[3].mode &= ~0222;
- table[4].mode &= ~0222;
}
hdr = register_net_sysctl_table(net, net_ipv4_ctl_path, table);
@@ -684,6 +686,11 @@ static void ip4_frags_ns_ctl_unregister(struct net *net)
unregister_net_sysctl_table(net->ipv4.frags_hdr);
kfree(table);
}
+
+static void ip4_frags_ctl_register(void)
+{
+ register_net_sysctl_rotable(net_ipv4_ctl_path, ip4_frags_ctl_table);
+}
#else
static inline int ip4_frags_ns_ctl_register(struct net *net)
{
@@ -693,6 +700,10 @@ static inline int ip4_frags_ns_ctl_register(struct net *net)
static inline void ip4_frags_ns_ctl_unregister(struct net *net)
{
}
+
+static inline void ip4_frags_ctl_register(void)
+{
+}
#endif
static int ipv4_frags_init_net(struct net *net)
@@ -730,6 +741,7 @@ static struct pernet_operations ip4_frags_ops = {
void __init ipfrag_init(void)
{
+ ip4_frags_ctl_register();
register_pernet_subsys(&ip4_frags_ops);
ip4_frags.hashfn = ip4_hashfn;
ip4_frags.constructor = ip4_frag_init;
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 130d6f6..9391a69 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -658,6 +658,10 @@ static struct ctl_table ip6_frags_ns_ctl_table[] = {
.proc_handler = &proc_dointvec_jiffies,
.strategy = &sysctl_jiffies,
},
+ { }
+};
+
+static struct ctl_table ip6_frags_ctl_table[] = {
{
.ctl_name = NET_IPV6_IP6FRAG_SECRET_INTERVAL,
.procname = "ip6frag_secret_interval",
@@ -684,7 +688,6 @@ static int ip6_frags_ns_sysctl_register(struct net *net)
table[0].data = &net->ipv6.frags.high_thresh;
table[1].data = &net->ipv6.frags.low_thresh;
table[2].data = &net->ipv6.frags.timeout;
- table[3].mode &= ~0222;
}
hdr = register_net_sysctl_table(net, net_ipv6_ctl_path, table);
@@ -709,6 +712,20 @@ static void ip6_frags_ns_sysctl_unregister(struct net *net)
unregister_net_sysctl_table(net->ipv6.sysctl.frags_hdr);
kfree(table);
}
+
+static struct ctl_table_header *ip6_ctl_header;
+
+static int ip6_frags_sysctl_register(void)
+{
+ ip6_ctl_header = register_net_sysctl_rotable(net_ipv6_ctl_path,
+ ip6_frags_ctl_table);
+ return ip6_ctl_header == NULL ? -ENOMEM : 0;
+}
+
+static void ip6_frags_sysctl_unregister(void)
+{
+ unregister_net_sysctl_table(ip6_ctl_header);
+}
#else
static inline int ip6_frags_ns_sysctl_register(struct net *net)
{
@@ -718,6 +735,15 @@ static inline int ip6_frags_ns_sysctl_register(struct net *net)
static inline void ip6_frags_ns_sysctl_unregister(struct net *net)
{
}
+
+static inline int ip6_frags_sysctl_register(void)
+{
+ return 0;
+}
+
+static inline void ip6_frags_sysctl_unregister(void)
+{
+}
#endif
static int ipv6_frags_init_net(struct net *net)
@@ -750,6 +776,10 @@ int __init ipv6_frag_init(void)
if (ret)
goto out;
+ ret = ip6_frags_sysctl_register();
+ if (ret)
+ goto err_sysctl;
+
ret = register_pernet_subsys(&ip6_frags_ops);
if (ret)
goto err_pernet;
@@ -767,6 +797,8 @@ out:
return ret;
err_pernet:
+ ip6_frags_sysctl_unregister();
+err_sysctl:
inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT);
goto out;
}
@@ -774,6 +806,7 @@ err_pernet:
void ipv6_frag_exit(void)
{
inet_frags_fini(&ip6_frags);
+ ip6_frags_sysctl_unregister();
unregister_pernet_subsys(&ip6_frags_ops);
inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT);
}
--
1.5.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH net-next 6/6][IPV6]: Register some net/ipv6/ core sysctls at read-only root.
2008-05-19 15:50 [PATCH net-next 0/6][NETNS]: Revisit read-only-in-namespaces sysctls Pavel Emelyanov
` (4 preceding siblings ...)
2008-05-19 16:04 ` [PATCH net-next 5/6][FRAGS]: Register some ctls at read-only root Pavel Emelyanov
@ 2008-05-19 16:06 ` Pavel Emelyanov
2008-05-19 20:54 ` David Miller
5 siblings, 1 reply; 13+ messages in thread
From: Pavel Emelyanov @ 2008-05-19 16:06 UTC (permalink / raw)
To: David Miller; +Cc: Linux Netdev List
There are some sysctls left to be switched to read-only,
but they are all in ipv6, so complete with them.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/ipv6/sysctl_net_ipv6.c | 29 ++++++++++++++++++++++-------
1 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
index 3804dcb..5c99274 100644
--- a/net/ipv6/sysctl_net_ipv6.c
+++ b/net/ipv6/sysctl_net_ipv6.c
@@ -37,6 +37,10 @@ static ctl_table ipv6_table_template[] = {
.mode = 0644,
.proc_handler = &proc_dointvec
},
+ { .ctl_name = 0 }
+};
+
+static ctl_table ipv6_table[] = {
{
.ctl_name = NET_IPV6_MLD_MAX_MSF,
.procname = "mld_max_msf",
@@ -80,12 +84,6 @@ static int ipv6_sysctl_net_init(struct net *net)
ipv6_table[2].data = &net->ipv6.sysctl.bindv6only;
- /* We don't want this value to be per namespace, it should be global
- to all namespaces, so make it read-only when we are not in the
- init network namespace */
- if (net != &init_net)
- ipv6_table[3].mode = 0444;
-
net->ipv6.sysctl.table = register_net_sysctl_table(net, net_ipv6_ctl_path,
ipv6_table);
if (!net->ipv6.sysctl.table)
@@ -126,12 +124,29 @@ static struct pernet_operations ipv6_sysctl_net_ops = {
.exit = ipv6_sysctl_net_exit,
};
+static struct ctl_table_header *ip6_header;
+
int ipv6_sysctl_register(void)
{
- return register_pernet_subsys(&ipv6_sysctl_net_ops);
+ int err = -ENOMEM;;
+
+ ip6_header = register_net_sysctl_rotable(net_ipv6_ctl_path, ipv6_table);
+ if (ip6_header == NULL)
+ goto out;
+
+ err = register_pernet_subsys(&ipv6_sysctl_net_ops);
+ if (err)
+ goto err_pernet;
+out:
+ return err;
+
+err_pernet:
+ unregister_net_sysctl_table(ip6_header);
+ goto out;
}
void ipv6_sysctl_unregister(void)
{
+ unregister_net_sysctl_table(ip6_header);
unregister_pernet_subsys(&ipv6_sysctl_net_ops);
}
--
1.5.3.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 1/6][NETNS]: Introduce sysctl root for read-only net sysctls.
2008-05-19 15:52 ` [PATCH net-next 1/6][NETNS]: Introduce sysctl root for read-only net sysctls Pavel Emelyanov
@ 2008-05-19 20:53 ` David Miller
0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2008-05-19 20:53 UTC (permalink / raw)
To: xemul; +Cc: netdev
From: Pavel Emelyanov <xemul@openvz.org>
Date: Mon, 19 May 2008 19:52:43 +0400
> This one stores all ctl-heads in one list and restricts the
> permissions not give write access to non-init net namespaces.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Applied.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 2/6][NETNS]: Register net/core/ sysctls at read-only root.
2008-05-19 15:55 ` [PATCH net-next 2/6][NETNS]: Register net/core/ sysctls at read-only root Pavel Emelyanov
@ 2008-05-19 20:53 ` David Miller
0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2008-05-19 20:53 UTC (permalink / raw)
To: xemul; +Cc: netdev
From: Pavel Emelyanov <xemul@openvz.org>
Date: Mon, 19 May 2008 19:55:01 +0400
> Most of the net/core/xxx sysctls are read-only now, but this
> goal is achieved with excessive memory consumption in each
> namespace - the whole table is cloned and most of the entries
> in it are ~= 0222.
>
> Split it into two parts and register (the largest) one at the
> read-only root.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Applied.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 3/6][FRAGS]: Rename sysctl-related functions/variables.
2008-05-19 15:58 ` [PATCH net-next 3/6][FRAGS]: Rename sysctl-related functions/variables Pavel Emelyanov
@ 2008-05-19 20:53 ` David Miller
0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2008-05-19 20:53 UTC (permalink / raw)
To: xemul; +Cc: netdev
From: Pavel Emelyanov <xemul@openvz.org>
Date: Mon, 19 May 2008 19:58:40 +0400
> The fragments sysctls also contains some, that are to be
> visible, but read-only in net namespaces.
>
> The naming in net/core/sysctl_net_core.c is - tables, that are
> to be registered in namespaces have a "ns" word in their names.
> So rename ones in ipv4/ip_fragment.c and ipv6/reassembly.c to
> fit this.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Applied.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 4/6][IP6FRAGS]: Handle error, returned from register_pernet_subsys.
2008-05-19 16:02 ` [PATCH net-next 4/6][IP6FRAGS]: Handle error, returned from register_pernet_subsys Pavel Emelyanov
@ 2008-05-19 20:54 ` David Miller
0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2008-05-19 20:54 UTC (permalink / raw)
To: xemul; +Cc: netdev
From: Pavel Emelyanov <xemul@openvz.org>
Date: Mon, 19 May 2008 20:02:25 +0400
> The error code is ignored now, but ipv6 is a module and one can
> be loaded under memory pressure, so the error may occur (in theory).
>
> Besides, I'm going to handle error returned from registering a
> read-only part of the table, so ignoring this one, while handing
> the other one would look strange.
>
> (However, this possibility of error is rather small, so I'm not
> sure whether this is a candidate for current net tree).
I definitely don't consider it -stable material.
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Applied, thanks!
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 5/6][FRAGS]: Register some ctls at read-only root.
2008-05-19 16:04 ` [PATCH net-next 5/6][FRAGS]: Register some ctls at read-only root Pavel Emelyanov
@ 2008-05-19 20:54 ` David Miller
0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2008-05-19 20:54 UTC (permalink / raw)
To: xemul; +Cc: netdev
From: Pavel Emelyanov <xemul@openvz.org>
Date: Mon, 19 May 2008 20:04:07 +0400
> Parts of fragments-related sysctls are read-only, but this is
> done by cloning all the tables and dropping write-bits from
> mode. Do the same but with read-only root.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Applied.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 6/6][IPV6]: Register some net/ipv6/ core sysctls at read-only root.
2008-05-19 16:06 ` [PATCH net-next 6/6][IPV6]: Register some net/ipv6/ core sysctls " Pavel Emelyanov
@ 2008-05-19 20:54 ` David Miller
0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2008-05-19 20:54 UTC (permalink / raw)
To: xemul; +Cc: netdev
From: Pavel Emelyanov <xemul@openvz.org>
Date: Mon, 19 May 2008 20:06:36 +0400
> There are some sysctls left to be switched to read-only,
> but they are all in ipv6, so complete with them.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Also applied, thanks a lot Pavel!
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2008-05-19 20:54 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-19 15:50 [PATCH net-next 0/6][NETNS]: Revisit read-only-in-namespaces sysctls Pavel Emelyanov
2008-05-19 15:52 ` [PATCH net-next 1/6][NETNS]: Introduce sysctl root for read-only net sysctls Pavel Emelyanov
2008-05-19 20:53 ` David Miller
2008-05-19 15:55 ` [PATCH net-next 2/6][NETNS]: Register net/core/ sysctls at read-only root Pavel Emelyanov
2008-05-19 20:53 ` David Miller
2008-05-19 15:58 ` [PATCH net-next 3/6][FRAGS]: Rename sysctl-related functions/variables Pavel Emelyanov
2008-05-19 20:53 ` David Miller
2008-05-19 16:02 ` [PATCH net-next 4/6][IP6FRAGS]: Handle error, returned from register_pernet_subsys Pavel Emelyanov
2008-05-19 20:54 ` David Miller
2008-05-19 16:04 ` [PATCH net-next 5/6][FRAGS]: Register some ctls at read-only root Pavel Emelyanov
2008-05-19 20:54 ` David Miller
2008-05-19 16:06 ` [PATCH net-next 6/6][IPV6]: Register some net/ipv6/ core sysctls " Pavel Emelyanov
2008-05-19 20:54 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).