[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>
This commit is contained in:
committed by
David S. Miller
parent
ad5d20a639
commit
b854272b3c
@@ -441,6 +441,7 @@ struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
|
||||
|
||||
static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
|
||||
{
|
||||
struct net *net = skb->sk->sk_net;
|
||||
struct nlattr *tb[IFA_MAX+1];
|
||||
struct in_device *in_dev;
|
||||
struct ifaddrmsg *ifm;
|
||||
@@ -449,6 +450,9 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg
|
||||
|
||||
ASSERT_RTNL();
|
||||
|
||||
if (net != &init_net)
|
||||
return -EINVAL;
|
||||
|
||||
err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv4_policy);
|
||||
if (err < 0)
|
||||
goto errout;
|
||||
@@ -560,10 +564,14 @@ errout:
|
||||
|
||||
static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
|
||||
{
|
||||
struct net *net = skb->sk->sk_net;
|
||||
struct in_ifaddr *ifa;
|
||||
|
||||
ASSERT_RTNL();
|
||||
|
||||
if (net != &init_net)
|
||||
return -EINVAL;
|
||||
|
||||
ifa = rtm_to_ifaddr(nlh);
|
||||
if (IS_ERR(ifa))
|
||||
return PTR_ERR(ifa);
|
||||
@@ -1174,12 +1182,16 @@ nla_put_failure:
|
||||
|
||||
static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
{
|
||||
struct net *net = skb->sk->sk_net;
|
||||
int idx, ip_idx;
|
||||
struct net_device *dev;
|
||||
struct in_device *in_dev;
|
||||
struct in_ifaddr *ifa;
|
||||
int s_ip_idx, s_idx = cb->args[0];
|
||||
|
||||
if (net != &init_net)
|
||||
return 0;
|
||||
|
||||
s_ip_idx = ip_idx = cb->args[1];
|
||||
idx = 0;
|
||||
for_each_netdev(&init_net, dev) {
|
||||
|
Reference in New Issue
Block a user