aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/fib_rules.c
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2007-11-30 08:21:31 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:54:24 -0500
commitb854272b3c732316676e9128f7b9e6f1e1ff88b0 (patch)
treec90c74b9ec068453881f1173da4c57d6bb00a7d9 /net/core/fib_rules.c
parentad5d20a63940fcfb40af76ba06148f36d5d0b433 (diff)
[NET]: Modify all rtnetlink methods to only work in the initial namespace (v2)
Before I can enable rtnetlink to work in all network namespaces I need to be certain that something won't break. So this patch deliberately disables all of the rtnletlink methods in everything except the initial network namespace. After the methods have been audited this extra check can be disabled. Changes from v1: - added IPv6 addrlabel protection Signed-off-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'net/core/fib_rules.c')
-rw-r--r--net/core/fib_rules.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 848132b6cb73..3b20b6f0982e 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -228,6 +228,9 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
228 struct nlattr *tb[FRA_MAX+1]; 228 struct nlattr *tb[FRA_MAX+1];
229 int err = -EINVAL, unresolved = 0; 229 int err = -EINVAL, unresolved = 0;
230 230
231 if (net != &init_net)
232 return -EINVAL;
233
231 if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*frh))) 234 if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*frh)))
232 goto errout; 235 goto errout;
233 236
@@ -358,12 +361,16 @@ errout:
358 361
359static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) 362static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
360{ 363{
364 struct net *net = skb->sk->sk_net;
361 struct fib_rule_hdr *frh = nlmsg_data(nlh); 365 struct fib_rule_hdr *frh = nlmsg_data(nlh);
362 struct fib_rules_ops *ops = NULL; 366 struct fib_rules_ops *ops = NULL;
363 struct fib_rule *rule, *tmp; 367 struct fib_rule *rule, *tmp;
364 struct nlattr *tb[FRA_MAX+1]; 368 struct nlattr *tb[FRA_MAX+1];
365 int err = -EINVAL; 369 int err = -EINVAL;
366 370
371 if (net != &init_net)
372 return -EINVAL;
373
367 if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*frh))) 374 if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*frh)))
368 goto errout; 375 goto errout;
369 376
@@ -539,9 +546,13 @@ skip:
539 546
540static int fib_nl_dumprule(struct sk_buff *skb, struct netlink_callback *cb) 547static int fib_nl_dumprule(struct sk_buff *skb, struct netlink_callback *cb)
541{ 548{
549 struct net *net = skb->sk->sk_net;
542 struct fib_rules_ops *ops; 550 struct fib_rules_ops *ops;
543 int idx = 0, family; 551 int idx = 0, family;
544 552
553 if (net != &init_net)
554 return -EINVAL;
555
545 family = rtnl_msg_family(cb->nlh); 556 family = rtnl_msg_family(cb->nlh);
546 if (family != AF_UNSPEC) { 557 if (family != AF_UNSPEC) {
547 /* Protocol specific dump request */ 558 /* Protocol specific dump request */