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: 10866125 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50CFE17EF for ; Fri, 22 Mar 2019 15:46:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3343F2A609 for ; Fri, 22 Mar 2019 15:46:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 277642A8BD; Fri, 22 Mar 2019 15:46:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C4AC2A609 for ; Fri, 22 Mar 2019 15:46:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727482AbfCVPqe (ORCPT ); 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-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-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;