From patchwork Tue Oct 15 16:45:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Mostafa X-Patchwork-Id: 283731 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 271662C020A for ; Wed, 16 Oct 2013 03:46:16 +1100 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1VW7l0-0004UH-Bz; Tue, 15 Oct 2013 16:46:06 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1VW7kv-0004TN-6Q for kernel-team@lists.ubuntu.com; Tue, 15 Oct 2013 16:46:01 +0000 Received: from c-67-160-231-162.hsd1.ca.comcast.net ([67.160.231.162] helo=fourier) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1VW7kt-0005NS-2M; Tue, 15 Oct 2013 16:45:59 +0000 Received: from kamal by fourier with local (Exim 4.80) (envelope-from ) id 1VW7kq-00087L-NE; Tue, 15 Oct 2013 09:45:56 -0700 From: Kamal Mostafa To: Jason Wang Subject: [ 3.8.y.z extended stable ] Patch "tuntap: correctly handle error in tun_set_iff()" has been added to staging queue Date: Tue, 15 Oct 2013 09:45:56 -0700 Message-Id: <1381855556-31175-1-git-send-email-kamal@canonical.com> X-Mailer: git-send-email 1.8.1.2 X-Extended-Stable: 3.8 Cc: "Michael S. Tsirkin" , Kamal Mostafa , Wannes Rombouts , kernel-team@lists.ubuntu.com, "David S. Miller" X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com This is a note to let you know that I have just added a patch titled tuntap: correctly handle error in tun_set_iff() to the linux-3.8.y-queue branch of the 3.8.y.z extended stable tree which can be found at: http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.8.y-queue This patch is scheduled to be released in version 3.8.13.12. If you, or anyone else, feels it should not be added to this tree, please reply to this email. For more information about the 3.8.y.z tree, see https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable Thanks. -Kamal ------ From 191766f0dc1904da11564ffa2823f3c7afd49eda Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Wed, 11 Sep 2013 18:09:48 +0800 Subject: tuntap: correctly handle error in tun_set_iff() commit 662ca437e714caaab855b12415d6ffd815985bc0 upstream. Commit c8d68e6be1c3b242f1c598595830890b65cea64a (tuntap: multiqueue support) only call free_netdev() on error in tun_set_iff(). This causes several issues: - memory of tun security were leaked - use after free since the flow gc timer was not deleted and the tfile were not detached This patch solves the above issues. Reported-by: Wannes Rombouts Cc: Michael S. Tsirkin Signed-off-by: Jason Wang Acked-by: Michael S. Tsirkin Signed-off-by: David S. Miller [ kamal: 3.8-stable for CVE-2013-4343 ] Cc: Luis Henriques Signed-off-by: Kamal Mostafa --- drivers/net/tun.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 1.8.1.2 diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 441c987..66b4613 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1686,11 +1686,11 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) INIT_LIST_HEAD(&tun->disabled); err = tun_attach(tun, file); if (err < 0) - goto err_free_dev; + goto err_free_flow; err = register_netdevice(tun->dev); if (err < 0) - goto err_free_dev; + goto err_detach; if (device_create_file(&tun->dev->dev, &dev_attr_tun_flags) || device_create_file(&tun->dev->dev, &dev_attr_owner) || @@ -1734,7 +1734,12 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) strcpy(ifr->ifr_name, tun->dev->name); return 0; - err_free_dev: +err_detach: + tun_detach_all(dev); +err_free_flow: + tun_flow_uninit(tun); + security_tun_dev_free_security(tun->security); +err_free_dev: free_netdev(dev); return err; }