From patchwork Wed Apr 20 10:04:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Henriques X-Patchwork-Id: 612605 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 3qqctg0vRRz9s0k; Wed, 20 Apr 2016 20:04:43 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1asozv-0004ml-TU; Wed, 20 Apr 2016 10:04:39 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1asozl-0004l6-Ve for kernel-team@lists.ubuntu.com; Wed, 20 Apr 2016 10:04:29 +0000 Received: from 1.general.henrix.uk.vpn ([10.172.192.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1asozl-0003We-KB; Wed, 20 Apr 2016 10:04:29 +0000 From: Luis Henriques To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/1] usbnet: cleanup after bind() in probe() Date: Wed, 20 Apr 2016 11:04:28 +0100 Message-Id: <1461146668-9239-2-git-send-email-luis.henriques@canonical.com> In-Reply-To: <1461146668-9239-1-git-send-email-luis.henriques@canonical.com> References: <1461146668-9239-1-git-send-email-luis.henriques@canonical.com> Cc: kamal@canonical.com 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 From: Oliver Neukum In case bind() works, but a later error forces bailing in probe() in error cases work and a timer may be scheduled. They must be killed. This fixes an error case related to the double free reported in http://www.spinics.net/lists/netdev/msg367669.html and needs to go on top of Linus' fix to cdc-ncm. Signed-off-by: Oliver Neukum Signed-off-by: David S. Miller (cherry picked from commit 1666984c8625b3db19a9abc298931d35ab7bc64b) CVE-2016-3951 BugLink: https://bugs.launchpad.net/bugs/1567191 Signed-off-by: Luis Henriques --- drivers/net/usb/usbnet.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 3b7b7b2eba1b..4abd4579ba0c 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -1719,6 +1719,13 @@ out3: if (info->unbind) info->unbind (dev, udev); out1: + /* subdrivers must undo all they did in bind() if they + * fail it, but we may fail later and a deferred kevent + * may trigger an error resubmitting itself and, worse, + * schedule a timer. So we kill it all just in case. + */ + cancel_work_sync(&dev->kevent); + del_timer_sync(&dev->delay); free_netdev(net); out: return status;