From patchwork Tue Dec 11 11:03:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [net-next, rfc, 1/2] tuntap: forbid calling TUNSETQUEUE for a persistent device with no queues From: Jason Wang X-Patchwork-Id: 205176 Message-Id: <1355223827-57290-2-git-send-email-jasowang@redhat.com> To: mst@redhat.com, pmoore@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: mprivozn@redhat.com, Jason Wang Date: Tue, 11 Dec 2012 19:03:46 +0800 When re-establish to a persistent deivce wihout queues attached, TUNSETIFF should be called instead of TUNSETQUEUE to do the proper permission checking. Signed-off-by: Jason Wang --- drivers/net/tun.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 14a0454..d593f56 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1771,6 +1771,9 @@ static int tun_set_queue(struct file *file, struct ifreq *ifr) ret = -EINVAL; else if (tun_not_capable(tun)) ret = -EPERM; + /* TUNSETIFF is needed to do permission checking */ + else if (tun->numqueues == 0) + ret = -EPERM; else ret = tun_attach(tun, file); } else if (ifr->ifr_flags & IFF_DETACH_QUEUE)