aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/rtnetlink.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/rtnetlink.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/rtnetlink.c')
-rw-r--r--net/core/rtnetlink.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index fed95a323b28..4edc3dac4ccd 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -703,6 +703,9 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
703 int s_idx = cb->args[0]; 703 int s_idx = cb->args[0];
704 struct net_device *dev; 704 struct net_device *dev;
705 705
706 if (net != &init_net)
707 return 0;
708
706 idx = 0; 709 idx = 0;
707 for_each_netdev(net, dev) { 710 for_each_netdev(net, dev) {
708 if (idx < s_idx) 711 if (idx < s_idx)
@@ -905,6 +908,9 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
905 struct nlattr *tb[IFLA_MAX+1]; 908 struct nlattr *tb[IFLA_MAX+1];
906 char ifname[IFNAMSIZ]; 909 char ifname[IFNAMSIZ];
907 910
911 if (net != &init_net)
912 return -EINVAL;
913
908 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy); 914 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy);
909 if (err < 0) 915 if (err < 0)
910 goto errout; 916 goto errout;
@@ -953,6 +959,9 @@ static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
953 struct nlattr *tb[IFLA_MAX+1]; 959 struct nlattr *tb[IFLA_MAX+1];
954 int err; 960 int err;
955 961
962 if (net != &init_net)
963 return -EINVAL;
964
956 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy); 965 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy);
957 if (err < 0) 966 if (err < 0)
958 return err; 967 return err;
@@ -1034,6 +1043,9 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
1034 struct nlattr *linkinfo[IFLA_INFO_MAX+1]; 1043 struct nlattr *linkinfo[IFLA_INFO_MAX+1];
1035 int err; 1044 int err;
1036 1045
1046 if (net != &init_net)
1047 return -EINVAL;
1048
1037#ifdef CONFIG_KMOD 1049#ifdef CONFIG_KMOD
1038replay: 1050replay:
1039#endif 1051#endif
@@ -1160,6 +1172,9 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
1160 struct sk_buff *nskb; 1172 struct sk_buff *nskb;
1161 int err; 1173 int err;
1162 1174
1175 if (net != &init_net)
1176 return -EINVAL;
1177
1163 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy); 1178 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy);
1164 if (err < 0) 1179 if (err < 0)
1165 return err; 1180 return err;
@@ -1195,9 +1210,13 @@ errout:
1195 1210
1196static int rtnl_dump_all(struct sk_buff *skb, struct netlink_callback *cb) 1211static int rtnl_dump_all(struct sk_buff *skb, struct netlink_callback *cb)
1197{ 1212{
1213 struct net *net = skb->sk->sk_net;
1198 int idx; 1214 int idx;
1199 int s_idx = cb->family; 1215 int s_idx = cb->family;
1200 1216
1217 if (net != &init_net)
1218 return 0;
1219
1201 if (s_idx == 0) 1220 if (s_idx == 0)
1202 s_idx = 1; 1221 s_idx = 1;
1203 for (idx=1; idx<NPROTO; idx++) { 1222 for (idx=1; idx<NPROTO; idx++) {