[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
@ -361,12 +361,16 @@ static const struct nla_policy ifal_policy[IFAL_MAX+1] = {
|
||||
static int ip6addrlbl_newdel(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
void *arg)
|
||||
{
|
||||
struct net *net = skb->sk->sk_net;
|
||||
struct ifaddrlblmsg *ifal;
|
||||
struct nlattr *tb[IFAL_MAX+1];
|
||||
struct in6_addr *pfx;
|
||||
u32 label;
|
||||
int err = 0;
|
||||
|
||||
if (net != &init_net)
|
||||
return 0;
|
||||
|
||||
err = nlmsg_parse(nlh, sizeof(*ifal), tb, IFAL_MAX, ifal_policy);
|
||||
if (err < 0)
|
||||
return err;
|
||||
@ -445,11 +449,15 @@ static int ip6addrlbl_fill(struct sk_buff *skb,
|
||||
|
||||
static int ip6addrlbl_dump(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
{
|
||||
struct net *net = skb->sk->sk_net;
|
||||
struct ip6addrlbl_entry *p;
|
||||
struct hlist_node *pos;
|
||||
int idx = 0, s_idx = cb->args[0];
|
||||
int err;
|
||||
|
||||
if (net != &init_net)
|
||||
return 0;
|
||||
|
||||
rcu_read_lock();
|
||||
hlist_for_each_entry_rcu(p, pos, &ip6addrlbl_table.head, list) {
|
||||
if (idx >= s_idx) {
|
||||
@ -479,6 +487,7 @@ static inline int ip6addrlbl_msgsize(void)
|
||||
static int ip6addrlbl_get(struct sk_buff *in_skb, struct nlmsghdr* nlh,
|
||||
void *arg)
|
||||
{
|
||||
struct net *net = in_skb->sk->sk_net;
|
||||
struct ifaddrlblmsg *ifal;
|
||||
struct nlattr *tb[IFAL_MAX+1];
|
||||
struct in6_addr *addr;
|
||||
@ -487,6 +496,9 @@ static int ip6addrlbl_get(struct sk_buff *in_skb, struct nlmsghdr* nlh,
|
||||
struct ip6addrlbl_entry *p;
|
||||
struct sk_buff *skb;
|
||||
|
||||
if (net != &init_net)
|
||||
return 0;
|
||||
|
||||
err = nlmsg_parse(nlh, sizeof(*ifal), tb, IFAL_MAX, ifal_policy);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
Reference in New Issue
Block a user