Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933338AbcDKNrh (ORCPT ); Mon, 11 Apr 2016 09:47:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:37391 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932432AbcDKNYD (ORCPT ); Mon, 11 Apr 2016 09:24:03 -0400 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" From: Jiri Slaby To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Oliver Neukum , Oliver Neukum , Jiri Slaby Subject: [PATCH 3.12 49/98] USB: usb_driver_claim_interface: add sanity checking Date: Mon, 11 Apr 2016 15:22:51 +0200 Message-Id: <177fb300cc272dc7a14b285357d47ca331ff8bdb.1460380917.git.jslaby@suse.cz> X-Mailer: git-send-email 2.8.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1126 Lines: 41 From: Oliver Neukum 3.12-stable review patch. If anyone has any objections, please let me know. =============== commit 0b818e3956fc1ad976bee791eadcbb3b5fec5bfd upstream. Attacks that trick drivers into passing a NULL pointer to usb_driver_claim_interface() using forged descriptors are known. This thwarts them by sanity checking. Signed-off-by: Oliver Neukum Signed-off-by: Jiri Slaby --- drivers/usb/core/driver.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index bfddeb3bc97e..8053fab9ae69 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -463,11 +463,15 @@ static int usb_unbind_interface(struct device *dev) int usb_driver_claim_interface(struct usb_driver *driver, struct usb_interface *iface, void *priv) { - struct device *dev = &iface->dev; + struct device *dev; struct usb_device *udev; int retval = 0; int lpm_disable_error; + if (!iface) + return -ENODEV; + + dev = &iface->dev; if (dev->driver) return -EBUSY; -- 2.8.1