* [PATCH] Allow group ownership of TUN/TAP devices (fwd)
@ 2007-06-18 16:16 James Morris
2007-06-19 5:36 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: James Morris @ 2007-06-18 16:16 UTC (permalink / raw)
To: netdev
---------- Forwarded message ----------
Date: Mon, 18 Jun 2007 12:05:49 -0400
From: Jeff Dike <jdike@addtoit.com>
To: maxk@qualcomm.com
Cc: Guido Guenther <agx@sigxcpu.org>, LKML <linux-kernel@vger.kernel.org>,
vtun@office.satix.net
Subject: [PATCH] Allow group ownership of TUN/TAP devices
I recieved from Guido Guenther the patch below to the TUN/TAP driver
which allows group ownerships to be effective.
It seems reasonable to me.
> the attached patches allow tun ownership by group. We found this useful
> since we can then spawn tapX devices on system boot (via
> /etc/network/interfaces) which logged on users can then use for their
> virtual machines.
>
> The first patch is for the kernel, the second one for the tunctl. They
> shouldn't change existing behaviour and we introduced a new syscall for
> the group setting. The user now is allowed to send packages if either
> his euid or his egid matches the one specified via tunctl (via -u or -g
> respecitvely). If both gid and uid are set via tunctl, both have to
> match. In case you find these useful, please apply.
--
Work email - jdike at linux dot intel dot com
From: Guido Guenther <agx@sigxcpu.org>
Date: Fri, 25 May 2007 11:10:27 +0200
Subject: [PATCH] allow tun ownership by group
---
drivers/net/tun.c | 15 +++++++++++++--
include/linux/if_tun.h | 2 ++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index a2c6caa..62b2b30 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -432,6 +432,7 @@ static void tun_setup(struct net_device *dev)
init_waitqueue_head(&tun->read_wait);
tun->owner = -1;
+ tun->group = -1;
SET_MODULE_OWNER(dev);
dev->open = tun_net_open;
@@ -467,8 +468,11 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr)
return -EBUSY;
/* Check permissions */
- if (tun->owner != -1 &&
- current->euid != tun->owner && !capable(CAP_NET_ADMIN))
+ if (((tun->owner != -1 &&
+ current->euid != tun->owner) ||
+ (tun->group != -1 &&
+ current->egid != tun->group)) &&
+ !capable(CAP_NET_ADMIN))
return -EPERM;
}
else if (__dev_get_by_name(ifr->ifr_name))
@@ -610,6 +614,13 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
DBG(KERN_INFO "%s: owner set to %d\n", tun->dev->name, tun->owner);
break;
+ case TUNSETGROUP:
+ /* Set group of the device */
+ tun->group= (gid_t) arg;
+
+ DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
+ break;
+
case TUNSETLINK:
/* Only allow setting the type when the interface is down */
if (tun->dev->flags & IFF_UP) {
diff --git a/include/linux/if_tun.h b/include/linux/if_tun.h
index 88aef7b..42eb694 100644
--- a/include/linux/if_tun.h
+++ b/include/linux/if_tun.h
@@ -36,6 +36,7 @@ struct tun_struct {
unsigned long flags;
int attached;
uid_t owner;
+ gid_t group;
wait_queue_head_t read_wait;
struct sk_buff_head readq;
@@ -78,6 +79,7 @@ struct tun_struct {
#define TUNSETPERSIST _IOW('T', 203, int)
#define TUNSETOWNER _IOW('T', 204, int)
#define TUNSETLINK _IOW('T', 205, int)
+#define TUNSETGROUP _IOW('T', 206, int)
/* TUNSETIFF ifr flags */
#define IFF_TUN 0x0001
--
1.5.1.4
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow group ownership of TUN/TAP devices (fwd)
2007-06-18 16:16 [PATCH] Allow group ownership of TUN/TAP devices (fwd) James Morris
@ 2007-06-19 5:36 ` David Miller
2007-06-21 14:59 ` Jeff Dike
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2007-06-19 5:36 UTC (permalink / raw)
To: jmorris; +Cc: netdev, jdike
From: James Morris <jmorris@namei.org>
Date: Mon, 18 Jun 2007 12:16:31 -0400 (EDT)
> ---------- Forwarded message ----------
> Date: Mon, 18 Jun 2007 12:05:49 -0400
> From: Jeff Dike <jdike@addtoit.com>
> To: maxk@qualcomm.com
> Cc: Guido Guenther <agx@sigxcpu.org>, LKML <linux-kernel@vger.kernel.org>,
> vtun@office.satix.net
> Subject: [PATCH] Allow group ownership of TUN/TAP devices
>
> I recieved from Guido Guenther the patch below to the TUN/TAP driver
> which allows group ownerships to be effective.
>
> It seems reasonable to me.
>
> > the attached patches allow tun ownership by group. We found this useful
> > since we can then spawn tapX devices on system boot (via
> > /etc/network/interfaces) which logged on users can then use for their
> > virtual machines.
> >
> > The first patch is for the kernel, the second one for the tunctl. They
> > shouldn't change existing behaviour and we introduced a new syscall for
> > the group setting. The user now is allowed to send packages if either
> > his euid or his egid matches the one specified via tunctl (via -u or -g
> > respecitvely). If both gid and uid are set via tunctl, both have to
> > match. In case you find these useful, please apply.
This patch looks fine.
I'd like it resubmitted with a proper changelog and signoff, and once
I have that I will thus queue it up for the 2.6.23 merge window.
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow group ownership of TUN/TAP devices (fwd)
2007-06-19 5:36 ` David Miller
@ 2007-06-21 14:59 ` Jeff Dike
2007-07-03 5:50 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Jeff Dike @ 2007-06-21 14:59 UTC (permalink / raw)
To: David Miller; +Cc: jmorris, netdev, Guido Guenther
On Mon, Jun 18, 2007 at 10:36:54PM -0700, David Miller wrote:
> This patch looks fine.
>
> I'd like it resubmitted with a proper changelog and signoff, and once
> I have that I will thus queue it up for the 2.6.23 merge window.
Introduce a new syscall TUNSETGROUP for group ownership setting of tap
devices. The user now is allowed to send packages if either his euid or
his egid matches the one specified via tunctl (via -u or -g
respecitvely). If both, gid and uid, are set via tunctl, both have to
match.
Signed-Off-By: Guido Guenther <agx@sigxcpu.org>
Signed-Off-By: Jeff Dike <jdike@linux.intel.com>
---
drivers/net/tun.c | 15 +++++++++++++--
include/linux/if_tun.h | 2 ++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index a2c6caa..62b2b30 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -432,6 +432,7 @@ static void tun_setup(struct net_device *dev)
init_waitqueue_head(&tun->read_wait);
tun->owner = -1;
+ tun->group = -1;
SET_MODULE_OWNER(dev);
dev->open = tun_net_open;
@@ -467,8 +468,11 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr)
return -EBUSY;
/* Check permissions */
- if (tun->owner != -1 &&
- current->euid != tun->owner && !capable(CAP_NET_ADMIN))
+ if (((tun->owner != -1 &&
+ current->euid != tun->owner) ||
+ (tun->group != -1 &&
+ current->egid != tun->group)) &&
+ !capable(CAP_NET_ADMIN))
return -EPERM;
}
else if (__dev_get_by_name(ifr->ifr_name))
@@ -610,6 +614,13 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
DBG(KERN_INFO "%s: owner set to %d\n", tun->dev->name, tun->owner);
break;
+ case TUNSETGROUP:
+ /* Set group of the device */
+ tun->group= (gid_t) arg;
+
+ DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
+ break;
+
case TUNSETLINK:
/* Only allow setting the type when the interface is down */
if (tun->dev->flags & IFF_UP) {
diff --git a/include/linux/if_tun.h b/include/linux/if_tun.h
index 88aef7b..42eb694 100644
--- a/include/linux/if_tun.h
+++ b/include/linux/if_tun.h
@@ -36,6 +36,7 @@ struct tun_struct {
unsigned long flags;
int attached;
uid_t owner;
+ gid_t group;
wait_queue_head_t read_wait;
struct sk_buff_head readq;
@@ -78,6 +79,7 @@ struct tun_struct {
#define TUNSETPERSIST _IOW('T', 203, int)
#define TUNSETOWNER _IOW('T', 204, int)
#define TUNSETLINK _IOW('T', 205, int)
+#define TUNSETGROUP _IOW('T', 206, int)
/* TUNSETIFF ifr flags */
#define IFF_TUN 0x0001
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow group ownership of TUN/TAP devices (fwd)
2007-06-21 14:59 ` Jeff Dike
@ 2007-07-03 5:50 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2007-07-03 5:50 UTC (permalink / raw)
To: jdike; +Cc: jmorris, netdev, agx
From: Jeff Dike <jdike@addtoit.com>
Date: Thu, 21 Jun 2007 10:59:11 -0400
> On Mon, Jun 18, 2007 at 10:36:54PM -0700, David Miller wrote:
> > This patch looks fine.
> >
> > I'd like it resubmitted with a proper changelog and signoff, and once
> > I have that I will thus queue it up for the 2.6.23 merge window.
>
> Introduce a new syscall TUNSETGROUP for group ownership setting of tap
> devices. The user now is allowed to send packages if either his euid or
> his egid matches the one specified via tunctl (via -u or -g
> respecitvely). If both, gid and uid, are set via tunctl, both have to
> match.
>
> Signed-Off-By: Guido Guenther <agx@sigxcpu.org>
> Signed-Off-By: Jeff Dike <jdike@linux.intel.com>
Patch applied, thanks a lot!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-07-03 5:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-18 16:16 [PATCH] Allow group ownership of TUN/TAP devices (fwd) James Morris
2007-06-19 5:36 ` David Miller
2007-06-21 14:59 ` Jeff Dike
2007-07-03 5:50 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).