From patchwork Fri Mar 22 15:43:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 160919 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp960825jan; Fri, 22 Mar 2019 08:46:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWo/6ALQvokoWuzw3nM8KnAKbHElgc9qPTgt1sIvY0xmADksNlRRMKQcVEbVnpHh8L0gaK X-Received: by 2002:a17:902:bd97:: with SMTP id q23mr10047984pls.94.1553269595919; Fri, 22 Mar 2019 08:46:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553269595; cv=none; d=google.com; s=arc-20160816; b=FObLGwQHZWxL0tJGmxAPGOP3Z1Da9QAgixaSTXn5LyPpJQf3KHFl/ZDQ2pK13cmVHI 4D7rGgOXExph/yxJJliOQI2EqcHuoezF1L1AcVaWekFlv8Ak2nZhsabjPOhcxv+7HBLl iYj68bks9NNH+z+DBA+4OjNT1vbex9XNRjeNV0iG4KB/J4QxWr2teMwQXCOxWu8grCQX oa9VKQcbq7X/8BmeqKawXaEkuVz2kxDGiUqVxPULKbcYuNmSHidBCuPoVcBID3M2/a5X sNmH1ehbRlVQsxRB9iR8lpq4ck42pPvXH3HteJB1+CxtGS5r+O/34cSqVTvrmjfO6eZX tYRw== 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 x6si6811326pgr.372.2019.03.22.08.46.35; Fri, 22 Mar 2019 08:46:35 -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 S1727668AbfCVPqe (ORCPT + 31 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 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(+) -- 2.20.0 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;