Patchwork [net-next,4/4] netns: bond: allow unprivileged users to control bond device

login
register
mail settings
Submitter Gao feng
Date Feb. 1, 2013, 2:31 a.m.
Message ID <1359685860-29636-4-git-send-email-gaofeng@cn.fujitsu.com>
Download mbox | patch
Permalink /patch/217335/
State Accepted
Delegated to: David Miller
Headers show

Comments

Gao feng - Feb. 1, 2013, 2:31 a.m.
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>
---
 drivers/net/bonding/bond_main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
David Miller - Feb. 4, 2013, 6:13 p.m.
From: Gao feng <gaofeng@cn.fujitsu.com>
Date: Fri, 1 Feb 2013 10:31:00 +0800

> 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>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index b38c9bf..2239937 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -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);
@@ -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);