Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 77CD6E00D35; Fri, 25 Nov 2016 03:30:53 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [185.38.180.44 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from smtp-out10.electric.net (smtp-out10.electric.net [185.38.180.44]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 0FEC3E00C80 for ; Fri, 25 Nov 2016 03:30:49 -0800 (PST) Received: from 1cAEiM-0003Re-VS by out10d.electric.net with emc1-ok (Exim 4.87) (envelope-from ) id 1cAEiN-0003SI-TC for meta-freescale@yoctoproject.org; Fri, 25 Nov 2016 03:30:47 -0800 Received: by emcmailer; Fri, 25 Nov 2016 03:30:47 -0800 Received: from [192.36.1.72] (helo=mx-3.enea.com) by out10d.electric.net with esmtps (TLSv1:AES128-SHA:128) (Exim 4.87) (envelope-from ) id 1cAEiM-0003Re-VS for meta-freescale@yoctoproject.org; Fri, 25 Nov 2016 03:30:46 -0800 Received: from sestofb10.enea.se (172.21.3.145) by smtp.enea.com (172.21.1.208) with Microsoft SMTP Server id 14.3.294.0; Fri, 25 Nov 2016 12:30:46 +0100 From: Sona Sarmadi To: Date: Fri, 25 Nov 2016 12:30:46 +0100 Message-ID: <1480073446-18089-1-git-send-email-sona.sarmadi@enea.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Received-SPF: None (SESTOEX08.enea.se: sona.sarmadi@enea.com does not designate permitted sender hosts) X-Outbound-IP: 192.36.1.72 X-Env-From: sona.sarmadi@enea.com X-Proto: esmtps X-Revdns: mx-3.enea.com X-HELO: mx-3.enea.com X-TLS: TLSv1:AES128-SHA:128 X-Authenticated_ID: X-PolicySMART: 6551647 X-Virus-Status: Scanned by VirusSMART (c) X-Virus-Status: Scanned by VirusSMART (s) Subject: [meta-fsl-ppc krogoth][PATCH] kernel: CVE-2015-8816 X-BeenThere: meta-freescale@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Usage and development list for the meta-fsl-* layers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Nov 2016 11:30:53 -0000 Content-Type: text/plain Fixes USB hub invalid memory access in hub_activate(). Reference: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-8816 Upstream fix: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/patch/?id=a706ac408da4994438d995d2cf4d2f7943086ca4 Signed-off-by: Sona Sarmadi --- recipes-kernel/linux/files/CVE-2015-8816.patch | 96 ++++++++++++++++++++++++++ recipes-kernel/linux/linux-qoriq_3.12.bb | 1 + 2 files changed, 97 insertions(+) create mode 100644 recipes-kernel/linux/files/CVE-2015-8816.patch diff --git a/recipes-kernel/linux/files/CVE-2015-8816.patch b/recipes-kernel/linux/files/CVE-2015-8816.patch new file mode 100644 index 0000000..a2bc55b --- /dev/null +++ b/recipes-kernel/linux/files/CVE-2015-8816.patch @@ -0,0 +1,96 @@ +From a706ac408da4994438d995d2cf4d2f7943086ca4 Mon Sep 17 00:00:00 2001 +From: Alan Stern +Date: Wed, 16 Dec 2015 13:32:38 -0500 +Subject: USB: fix invalid memory access in hub_activate() + +commit e50293ef9775c5f1cf3fcc093037dd6a8c5684ea upstream. + +Commit 8520f38099cc ("USB: change hub initialization sleeps to +delayed_work") changed the hub_activate() routine to make part of it +run in a workqueue. However, the commit failed to take a reference to +the usb_hub structure or to lock the hub interface while doing so. As +a result, if a hub is plugged in and quickly unplugged before the work +routine can run, the routine will try to access memory that has been +deallocated. Or, if the hub is unplugged while the routine is +running, the memory may be deallocated while it is in active use. + +This patch fixes the problem by taking a reference to the usb_hub at +the start of hub_activate() and releasing it at the end (when the work +is finished), and by locking the hub interface while the work routine +is running. It also adds a check at the start of the routine to see +if the hub has already been disconnected, in which nothing should be +done. + +CVE: CVE-2015-8816 +Upstream-Status: Backport + +Signed-off-by: Alan Stern +Reported-by: Alexandru Cornea +Tested-by: Alexandru Cornea +Fixes: 8520f38099cc ("USB: change hub initialization sleeps to delayed_work") +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Jiri Slaby +Signed-off-by: Sona Sarmadi +--- + drivers/usb/core/hub.c | 23 ++++++++++++++++++++--- + 1 file changed, 20 insertions(+), 3 deletions(-) + +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c +index a7de5da..fdcf290 100644 +--- a/drivers/usb/core/hub.c ++++ b/drivers/usb/core/hub.c +@@ -114,6 +114,7 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem); + #define HUB_DEBOUNCE_STABLE 100 + + static int usb_reset_and_verify_device(struct usb_device *udev); ++static void hub_release(struct kref *kref); + + static inline char *portspeed(struct usb_hub *hub, int portstatus) + { +@@ -1030,10 +1031,20 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) + unsigned delay; + + /* Continue a partial initialization */ +- if (type == HUB_INIT2) +- goto init2; +- if (type == HUB_INIT3) ++ if (type == HUB_INIT2 || type == HUB_INIT3) { ++ device_lock(hub->intfdev); ++ ++ /* Was the hub disconnected while we were waiting? */ ++ if (hub->disconnected) { ++ device_unlock(hub->intfdev); ++ kref_put(&hub->kref, hub_release); ++ return; ++ } ++ if (type == HUB_INIT2) ++ goto init2; + goto init3; ++ } ++ kref_get(&hub->kref); + + /* The superspeed hub except for root hub has to use Hub Depth + * value as an offset into the route string to locate the bits +@@ -1230,6 +1241,7 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) + PREPARE_DELAYED_WORK(&hub->init_work, hub_init_func3); + schedule_delayed_work(&hub->init_work, + msecs_to_jiffies(delay)); ++ device_unlock(hub->intfdev); + return; /* Continues at init3: below */ + } else { + msleep(delay); +@@ -1250,6 +1262,11 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) + /* Allow autosuspend if it was suppressed */ + if (type <= HUB_INIT3) + usb_autopm_put_interface_async(to_usb_interface(hub->intfdev)); ++ ++ if (type == HUB_INIT2 || type == HUB_INIT3) ++ device_unlock(hub->intfdev); ++ ++ kref_put(&hub->kref, hub_release); + } + + /* Implement the continuations for the delays above */ +-- +cgit v0.12 + diff --git a/recipes-kernel/linux/linux-qoriq_3.12.bb b/recipes-kernel/linux/linux-qoriq_3.12.bb index e3ba079..a9dee4c 100644 --- a/recipes-kernel/linux/linux-qoriq_3.12.bb +++ b/recipes-kernel/linux/linux-qoriq_3.12.bb @@ -7,5 +7,6 @@ SRC_URI = "git://git.freescale.com/ppc/sdk/linux.git;branch=sdk-v1.9.x \ file://Trusty-SRU-ipc-fix-compat-msgrcv-with-negative-msgtyp.patch \ file://CVE-2015-8539.patch \ file://CVE-2015-8767.patch \ + file://CVE-2015-8816.patch \ " SRCREV = "43cecda943a6c40a833b588801b0929e8bd48813" -- 1.9.1