Commit 276996fd authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller

net: Allow the userns root to control vlans.

Allow an unpriviled user who has created a user namespace, and then
created a network namespace to effectively use the new network
namespace, by reducing capable(CAP_NET_ADMIN) and
capable(CAP_NET_RAW) calls to be ns_capable(net->user_ns,
CAP_NET_ADMIN), or capable(net->user_ns, CAP_NET_RAW) calls.

Allow the vlan ioctls:
SET_VLAN_INGRESS_PRIORITY_CMD
SET_VLAN_EGRESS_PRIORITY_CMD
SET_VLAN_FLAG_CMD
SET_VLAN_NAME_TYPE_CMD
ADD_VLAN_CMD
DEL_VLAN_CMD
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cb990503
...@@ -529,7 +529,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg) ...@@ -529,7 +529,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
switch (args.cmd) { switch (args.cmd) {
case SET_VLAN_INGRESS_PRIORITY_CMD: case SET_VLAN_INGRESS_PRIORITY_CMD:
err = -EPERM; err = -EPERM;
if (!capable(CAP_NET_ADMIN)) if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
break; break;
vlan_dev_set_ingress_priority(dev, vlan_dev_set_ingress_priority(dev,
args.u.skb_priority, args.u.skb_priority,
...@@ -539,7 +539,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg) ...@@ -539,7 +539,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
case SET_VLAN_EGRESS_PRIORITY_CMD: case SET_VLAN_EGRESS_PRIORITY_CMD:
err = -EPERM; err = -EPERM;
if (!capable(CAP_NET_ADMIN)) if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
break; break;
err = vlan_dev_set_egress_priority(dev, err = vlan_dev_set_egress_priority(dev,
args.u.skb_priority, args.u.skb_priority,
...@@ -548,7 +548,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg) ...@@ -548,7 +548,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
case SET_VLAN_FLAG_CMD: case SET_VLAN_FLAG_CMD:
err = -EPERM; err = -EPERM;
if (!capable(CAP_NET_ADMIN)) if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
break; break;
err = vlan_dev_change_flags(dev, err = vlan_dev_change_flags(dev,
args.vlan_qos ? args.u.flag : 0, args.vlan_qos ? args.u.flag : 0,
...@@ -557,7 +557,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg) ...@@ -557,7 +557,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
case SET_VLAN_NAME_TYPE_CMD: case SET_VLAN_NAME_TYPE_CMD:
err = -EPERM; err = -EPERM;
if (!capable(CAP_NET_ADMIN)) if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
break; break;
if ((args.u.name_type >= 0) && if ((args.u.name_type >= 0) &&
(args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) { (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
...@@ -573,14 +573,14 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg) ...@@ -573,14 +573,14 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
case ADD_VLAN_CMD: case ADD_VLAN_CMD:
err = -EPERM; err = -EPERM;
if (!capable(CAP_NET_ADMIN)) if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
break; break;
err = register_vlan_device(dev, args.u.VID); err = register_vlan_device(dev, args.u.VID);
break; break;
case DEL_VLAN_CMD: case DEL_VLAN_CMD:
err = -EPERM; err = -EPERM;
if (!capable(CAP_NET_ADMIN)) if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
break; break;
unregister_vlan_dev(dev, NULL); unregister_vlan_dev(dev, NULL);
err = 0; err = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment