Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp798345img; Fri, 22 Mar 2019 08:47:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyV2KxQ6EFYKXX9T7uvuq4tcisjKuvSVHmRrquuaghW8T7OfPHLvERLyDHKzmpWUKIcH9rF X-Received: by 2002:a62:2fc4:: with SMTP id v187mr10240075pfv.147.1553269656038; Fri, 22 Mar 2019 08:47:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553269656; cv=none; d=google.com; s=arc-20160816; b=i4+z2BKPYtNzeCGDm9SvLujeV5hnD6oXDSXBFQkg2WJUwGe0S0DbuhlUvRhJK11l/7 1CI/kUGL4QWFiuq474hiM8/dkXc/V72LISvr+psexK9aNqA/EJcS6jwmznLcTMovjqtI wFDHE0SHxtgBtZ02jmzhip1J2pVzvqYRZpAznTC1d1RUyL21sG32v4Vd6Bul4UJRhtE8 Ph/JNk6VYdDH8F33qfsOccboRfPtmWogNNHqazbhuucPv7E6MmiiB4JZa6SRyYEUyj60 VkrPHA0LEMmQPPVNlr3RboCIAG1m3I0n/ZsChxq9PmzXBS0Uf9FNz2kw5l8kVH8nh6qm Pv5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=iHpmuZgDmvgfGvYU1MpxCv9KM815GPaZphUjzl8oS/M=; b=BAvg7r5DtcV8Y/pHEXZhYZMHYywNQeVvYDx/7fsQ/Plq7ScmmvoktRF3jO4N/v5u36 tl+ZqQij+hczVfhaMk5JjHuYMSAZNEYT3xWO3rQtPsFOrr7BdyUKUpxNYjlomMaF3uUF gX4xrKnPh76YuAgwbiglOJnG0AONSSVzifRk9qXB/oPfMPeSayTiK4IhKuJHECa6IVRi COIuCSVZwm/sLhr6LcokyYaw2XQyIueChV0UHOwzlzfigZfGYnp4ppHx0zf/GtfF8cf3 Y42Y0pNMKsRHIZ+4/gZ5G6bPyWWtftpqtJ5lbJ4kMiYd09uor1WA+UQARwU+yhZYI3sq gQzw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l17si6710901pff.202.2019.03.22.08.47.21; Fri, 22 Mar 2019 08:47:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727662AbfCVPqe (ORCPT + 99 others); Fri, 22 Mar 2019 11:46:34 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:53763 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727231AbfCVPqd (ORCPT ); Fri, 22 Mar 2019 11:46:33 -0400 Received: from wuerfel.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MPGNn-1hLTwE0CPV-00PeTX; Fri, 22 Mar 2019 16:45:47 +0100 From: Arnd Bergmann To: stable@vger.kernel.org, Greg Kroah-Hartman , Kees Cook , Sebastian Andrzej Siewior , "Gustavo A. R. Silva" Cc: Josh Boyer , Ralf Spenneberg , Arnd Bergmann , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [BACKPORT 4.4.y 04/25] USB: iowarrior: fix oops with malicious USB descriptors Date: Fri, 22 Mar 2019 16:43:55 +0100 Message-Id: <20190322154425.3852517-5-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190322154425.3852517-1-arnd@arndb.de> References: <20190322154425.3852517-1-arnd@arndb.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:qmHMR6/bLkiLAr6Eh2kVU9pjqymM3CZ//BPIzKS9tQMm0ixAiTF UDcP/qFX/IfUNIqGdzDcm3t6cYrK1TzuehVrLBWoIPwmi4QCd79Ub21akCYkHMBqwgaB+ak B2e6Y0ZRK1u/4/qljIYX+imdGR6mUAiKfBTsE+mqTpMSXTgyENA5PtP2Ax4XSCgmAfjTTrS 5tn1Y0+gG5FBJsQHdJNHw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:cNE/gt7wInI=:X1hTqeX42BmVm0QmBW7HVM gVZtXD1fAtJajFgUOweHQIUvZnoZL/bhdW4cs8FRpVwEJ6TmJqm8cylXOp9S1qjIPMjLL5J3z Dyu1KubI313MMSs6M/hlMdZRqwcTU8T7T69C2kvNMJFetHZdprrQgerbJF0NT1Q5bPPM5Kkn1 /9A+c9mX+U06ixiHxSAQqKD9GgCBu0iaATVNsxQswp2o+fBbpEhvZE4gy/T5pjhZuzONeXPsk zcT1QaXS+wosEnUdW4K4nQt1iVXrM8GlJBBNnlYJH+9SlQ2BeWY6AKsxSDG0Ng4F4JhH2E946 r2ZkIgF3eE7VUKjtcgTZ3x66RoToNXULPU3KDh49rXEZMxwhqLvvdC6tGWkAUXrPhFV7cO7YI VT5mmijaXuQw8pOuXRsha7wXpuUdqvFZMBYRL7UDVVFIEtMbyn/FAnm6RSSxVyND9gR8XCdgb tTelA15LWI0ypLdoAi67uhWOiF7u0wHQ/UXDgI6FfhICF/4EGZYtwCpTSQQMrLi5Jngj8ED01 Gd5c/KmzwgPlrdv/SAUk0V/i1PCG2X2XQ8azqVLWwriPxA5Klt+h8H+gy5skj4s2TQBayq3yL a0k56Yt0kdAaiG5SfXBVw/1hexum9pgLAx2CA51pPLBwoevmtSmWCanKNgYnBE1Xg9l97e93v jWiiBcWNmDlDZD2GV2R+ShHRji0HLKHKS0FRWJEv3ZZlDHFxYn1PkoTwvO9AiaDCGcnTpNmYm MrqHgTRWq0fHjh/EpZlP2jaxZ9ZbZX2u7tAFNQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josh Boyer The iowarrior driver expects at least one valid endpoint. If given malicious descriptors that specify 0 for the number of endpoints, it will crash in the probe function. Ensure there is at least one endpoint on the interface before using it. The full report of this issue can be found here: http://seclists.org/bugtraq/2016/Mar/87 Reported-by: Ralf Spenneberg Cc: stable Signed-off-by: Josh Boyer Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 4ec0ef3a82125efc36173062a50624550a900ae0) Signed-off-by: Arnd Bergmann --- drivers/usb/misc/iowarrior.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index 5e43fd881a9c..381a92a0ebb6 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c @@ -787,6 +787,12 @@ static int iowarrior_probe(struct usb_interface *interface, iface_desc = interface->cur_altsetting; dev->product_id = le16_to_cpu(udev->descriptor.idProduct); + if (iface_desc->desc.bNumEndpoints < 1) { + dev_err(&interface->dev, "Invalid number of endpoints\n"); + retval = -EINVAL; + goto error; + } + /* set up the endpoint information */ for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; -- 2.20.0