aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 33b6d1b122fb..55dc70c6b4db 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -702,6 +702,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
702 struct tun_net *tn; 702 struct tun_net *tn;
703 struct tun_struct *tun; 703 struct tun_struct *tun;
704 struct net_device *dev; 704 struct net_device *dev;
705 const struct cred *cred = current_cred();
705 int err; 706 int err;
706 707
707 tn = net_generic(net, tun_net_id); 708 tn = net_generic(net, tun_net_id);
@@ -712,11 +713,12 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
712 713
713 /* Check permissions */ 714 /* Check permissions */
714 if (((tun->owner != -1 && 715 if (((tun->owner != -1 &&
715 current->euid != tun->owner) || 716 cred->euid != tun->owner) ||
716 (tun->group != -1 && 717 (tun->group != -1 &&
717 current->egid != tun->group)) && 718 cred->egid != tun->group)) &&
718 !capable(CAP_NET_ADMIN)) 719 !capable(CAP_NET_ADMIN)) {
719 return -EPERM; 720 return -EPERM;
721 }
720 } 722 }
721 else if (__dev_get_by_name(net, ifr->ifr_name)) 723 else if (__dev_get_by_name(net, ifr->ifr_name))
722 return -EINVAL; 724 return -EINVAL;