diff options
author | Denis V. Lunev <den@openvz.org> | 2007-12-01 00:21:31 +1100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 14:54:24 -0800 |
commit | b854272b3c732316676e9128f7b9e6f1e1ff88b0 (patch) | |
tree | c90c74b9ec068453881f1173da4c57d6bb00a7d9 /net/core/neighbour.c | |
parent | ad5d20a63940fcfb40af76ba06148f36d5d0b433 (diff) | |
download | linux-b854272b3c732316676e9128f7b9e6f1e1ff88b0.tar.gz linux-b854272b3c732316676e9128f7b9e6f1e1ff88b0.tar.bz2 linux-b854272b3c732316676e9128f7b9e6f1e1ff88b0.zip |
[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/neighbour.c')
-rw-r--r-- | net/core/neighbour.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 175bbc0a974e..29f0a4d2008f 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -1449,6 +1449,9 @@ static int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) struct net_device *dev = NULL; int err = -EINVAL; + if (net != &init_net) + return -EINVAL; + if (nlmsg_len(nlh) < sizeof(*ndm)) goto out; @@ -1515,6 +1518,9 @@ static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) struct net_device *dev = NULL; int err; + if (net != &init_net) + return -EINVAL; + err = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, NULL); if (err < 0) goto out; @@ -1789,11 +1795,15 @@ static const struct nla_policy nl_ntbl_parm_policy[NDTPA_MAX+1] = { static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) { + struct net *net = skb->sk->sk_net; struct neigh_table *tbl; struct ndtmsg *ndtmsg; struct nlattr *tb[NDTA_MAX+1]; int err; + if (net != &init_net) + return -EINVAL; + err = nlmsg_parse(nlh, sizeof(*ndtmsg), tb, NDTA_MAX, nl_neightbl_policy); if (err < 0) @@ -1913,11 +1923,15 @@ errout: static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb) { + struct net *net = skb->sk->sk_net; int family, tidx, nidx = 0; int tbl_skip = cb->args[0]; int neigh_skip = cb->args[1]; struct neigh_table *tbl; + if (net != &init_net) + return 0; + family = ((struct rtgenmsg *) nlmsg_data(cb->nlh))->rtgen_family; read_lock(&neigh_tbl_lock); @@ -2042,9 +2056,13 @@ out: static int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb) { + struct net *net = skb->sk->sk_net; struct neigh_table *tbl; int t, family, s_t; + if (net != &init_net) + return 0; + read_lock(&neigh_tbl_lock); family = ((struct rtgenmsg *) nlmsg_data(cb->nlh))->rtgen_family; s_t = cb->args[0]; |