net: Allow userns root to control tun and tap devices
Subsystems (3)
PATCH 1/1 net: Allow userns root to control tun and tap devices
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) calls to ns_capable(net->user_ns,CAP_NET_ADMIN) calls.
Allow setting of the tun iff flags.
Allow creating of tun devices.
Allow adding a new queue to a tun device.
--- drivers/net/tun.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/tun.c +3 -2
@@ -373,10 +373,11 @@ static u16 tun_select_queue(struct net_device *dev, struct sk_buff *skb)static inline bool tun_not_capable (struct tun_struct *tun) {const struct cred *cred =current_cred (); +struct net *net =dev_net (tun->dev);return ((uid_valid (tun->owner) && !uid_eq (cred->euid, tun->owner)) || (gid_valid (tun->group) && !in_egroup_p (tun->group))) && - !capable (CAP_NET_ADMIN ); + !ns_capable (net->user_ns,CAP_NET_ADMIN ); }static void tun_set_real_num_queues (struct tun_struct *tun)
@@ -1559,7 +1560,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)char *name;unsigned long flags =0 ; -if (!capable (CAP_NET_ADMIN )) +if (!ns_capable (net->user_ns,CAP_NET_ADMIN ))return -EPERM ; err =security_tun_dev_create ();if (err <0 )
Signature · 1 line
1.7.5.4
A message that is not in the archive (sent off-list or not yet received): 87a9uekpvw.fsf-aS9lmoZGLiVWk0Htik3J/[email protected]
Serge E. Hallyn
Acked-by Serge HallynQuoted 10 lines · Eric W. Biederman
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)calls tons_capable(net->user_ns,CAP_NET_ADMIN)calls.Allow setting of the tun iff flags.
Allow creating of tun devices.
Allow adding a new queue to a tun device.
Quoted 33 lines
--- drivers/net/tun.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)drivers/net/tun.c +3
-2@@ -373,10 +373,11 @@ static u16 tun_select_queue(struct net_device *dev, struct sk_buff *skb)static inline bool tun_not_capable (struct tun_struct *tun) {const struct cred *cred =current_cred (); +struct net *net =dev_net (tun->dev);return ((uid_valid (tun->owner) && !uid_eq (cred->euid, tun->owner)) || (gid_valid (tun->group) && !in_egroup_p (tun->group))) && - !capable (CAP_NET_ADMIN ); + !ns_capable (net->user_ns,CAP_NET_ADMIN ); }static void tun_set_real_num_queues (struct tun_struct *tun)@@ -1559,7 +1560,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)char *name;unsigned long flags =0 ; -if (!capable (CAP_NET_ADMIN )) +if (!ns_capable (net->user_ns,CAP_NET_ADMIN ))return -EPERM ; err =security_tun_dev_create ();if (err <0 )Signature · 1 line
1.7.5.4
A message that is not in the archive (sent off-list or not yet received): [email protected]
David Miller
AppliedFrom: "Serge E. Hallyn" <[email protected]>
Date: Mon, 19 Nov 2012 14:23:31 +0000
Quoted 7 lines · Eric W. Biederman
Quoted 6 lines
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)calls tons_capable(net->user_ns,CAP_NET_ADMIN)calls.
Quoted 6 lines
Quoted 4 lines
Allow setting of the tun iff flags.
Allow creating of tun devices.
Allow adding a new queue to a tun device.Acked-by Serge Hallyn <[email protected]>
Applied.