Skip to content

Commit

Permalink
netns: bond: allow unprivileged users to control bond device
Browse files Browse the repository at this point in the history
reduce the permission check of bond device's ioctl.
allow the userns root to control the bond device.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Gao feng authored and David S. Miller committed Feb 4, 2013
1 parent e4d343e commit 387ff91
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/net/bonding/bond_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3612,6 +3612,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
struct ifslave k_sinfo;
struct ifslave __user *u_sinfo = NULL;
struct mii_ioctl_data *mii = NULL;
struct net *net;
int res = 0;

pr_debug("bond_ioctl: master=%s, cmd=%d\n", bond_dev->name, cmd);
Expand Down Expand Up @@ -3678,10 +3679,12 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
break;
}

if (!capable(CAP_NET_ADMIN))
net = dev_net(bond_dev);

if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
return -EPERM;

slave_dev = dev_get_by_name(dev_net(bond_dev), ifr->ifr_slave);
slave_dev = dev_get_by_name(net, ifr->ifr_slave);

pr_debug("slave_dev=%p:\n", slave_dev);

Expand Down

0 comments on commit 387ff91

Please sign in to comment.