Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 133881
b: refs/heads/master
c: 38231b7
h: refs/heads/master
i:
  133879: 6e7624a
v: v3
  • Loading branch information
Eric W. Biederman authored and David S. Miller committed Jan 22, 2009
1 parent 9dc54ee commit e6c929d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 36b50bab53207daf34be63ca62fb8b0b08dc6e6b
refs/heads/master: 38231b7a8d1b74c920822640d1ce8eb8046377fb
24 changes: 17 additions & 7 deletions trunk/drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,34 +115,44 @@ static int tun_attach(struct tun_struct *tun, struct file *file)
{
struct tun_file *tfile = file->private_data;
const struct cred *cred = current_cred();
int err;

ASSERT_RTNL();

if (tfile->tun)
return -EINVAL;

if (tun->tfile)
return -EBUSY;

/* Check permissions */
if (((tun->owner != -1 && cred->euid != tun->owner) ||
(tun->group != -1 && cred->egid != tun->group)) &&
!capable(CAP_NET_ADMIN))
return -EPERM;

netif_tx_lock_bh(tun->dev);

err = -EINVAL;
if (tfile->tun)
goto out;

err = -EBUSY;
if (tun->tfile)
goto out;

err = 0;
tfile->tun = tun;
tun->tfile = tfile;

return 0;
out:
netif_tx_unlock_bh(tun->dev);
return err;
}

static void __tun_detach(struct tun_struct *tun)
{
struct tun_file *tfile = tun->tfile;

/* Detach from net device */
netif_tx_lock_bh(tun->dev);
tfile->tun = NULL;
tun->tfile = NULL;
netif_tx_unlock_bh(tun->dev);

/* Drop read queue */
skb_queue_purge(&tun->readq);
Expand Down

0 comments on commit e6c929d

Please sign in to comment.