Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric W. Biederman and committed by
David S. Miller
276996fd cb990503

+6 -6
+6 -6
net/8021q/vlan.c
··· 529 529 switch (args.cmd) { 530 530 case SET_VLAN_INGRESS_PRIORITY_CMD: 531 531 err = -EPERM; 532 - if (!capable(CAP_NET_ADMIN)) 532 + if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 533 533 break; 534 534 vlan_dev_set_ingress_priority(dev, 535 535 args.u.skb_priority, ··· 539 539 540 540 case SET_VLAN_EGRESS_PRIORITY_CMD: 541 541 err = -EPERM; 542 - if (!capable(CAP_NET_ADMIN)) 542 + if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 543 543 break; 544 544 err = vlan_dev_set_egress_priority(dev, 545 545 args.u.skb_priority, ··· 548 548 549 549 case SET_VLAN_FLAG_CMD: 550 550 err = -EPERM; 551 - if (!capable(CAP_NET_ADMIN)) 551 + if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 552 552 break; 553 553 err = vlan_dev_change_flags(dev, 554 554 args.vlan_qos ? args.u.flag : 0, ··· 557 557 558 558 case SET_VLAN_NAME_TYPE_CMD: 559 559 err = -EPERM; 560 - if (!capable(CAP_NET_ADMIN)) 560 + if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 561 561 break; 562 562 if ((args.u.name_type >= 0) && 563 563 (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) { ··· 573 573 574 574 case ADD_VLAN_CMD: 575 575 err = -EPERM; 576 - if (!capable(CAP_NET_ADMIN)) 576 + if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 577 577 break; 578 578 err = register_vlan_device(dev, args.u.VID); 579 579 break; 580 580 581 581 case DEL_VLAN_CMD: 582 582 err = -EPERM; 583 - if (!capable(CAP_NET_ADMIN)) 583 + if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 584 584 break; 585 585 unregister_vlan_dev(dev, NULL); 586 586 err = 0;