tuntap: refuse to re-attach to different tun_struct
[profile/ivi/kernel-adaptation-intel-automotive.git] / drivers / net / tun.c
index fbd106e..cf6da6e 100644 (file)
@@ -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)