Skip to content

Commit

Permalink
tuntap: refuse to re-attach to different tun_struct
Browse files Browse the repository at this point in the history
Multiqueue tun devices support detaching a tun_file from its tun_struct
and re-attaching at a later point in time.  This allows users to disable
a specific queue temporarily.

ioctl(TUNSETIFF) allows the user to specify the network interface to
attach by name.  This means the user can attempt to attach to interface
"B" after detaching from interface "A".

The driver is not designed to support this so check we are re-attaching
to the right tun_struct.  Failure to do so may lead to oops.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Stefan Hajnoczi authored and David S. Miller committed Jan 10, 2013
1 parent 21caa66 commit 6e331f4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,8 @@ static int tun_attach(struct tun_struct *tun, struct file *file)
err = -EINVAL;
if (rcu_dereference_protected(tfile->tun, lockdep_rtnl_is_held()))
goto out;
if (tfile->detached && tun != tfile->detached)
goto out;

err = -EBUSY;
if (!(tun->flags & TUN_TAP_MQ) && tun->numqueues == 1)
Expand Down

0 comments on commit 6e331f4

Please sign in to comment.