From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 097A1C4CED1 for ; Thu, 3 Oct 2019 17:27:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C8A4720830 for ; Thu, 3 Oct 2019 17:27:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570123642; bh=rXSuWWeH3sDfoofSnPCEWC5e/wGIuwV3gpWgxhVBfvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=lVGul/fcezKk9R6ka9yyGQThuTR/+P+Qm9GxpiNgpuWQdVEZ3pKp+ByAVTInKT8e6 XdsOIYum7Wb9ZfYgt7bW5l9nwvLcmFrQasWJY5JgO63lfMXKUnSqhqj+Om73YWY6St xk2GlGvMHF/h9tROElsn42zrJpFlisoHsQz4AmVw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388758AbfJCQO7 (ORCPT ); Thu, 3 Oct 2019 12:14:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:38612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388740AbfJCQOz (ORCPT ); Thu, 3 Oct 2019 12:14:55 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E0C5620865; Thu, 3 Oct 2019 16:14:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570119295; bh=rXSuWWeH3sDfoofSnPCEWC5e/wGIuwV3gpWgxhVBfvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AtrMfo4Sby58MWvp3Bt5O8gREa9q2ZExNh6g1+PRb+seoa70051I4xCCEjbJJ5fSv 1832HkXHhwzmvw9jS0ENXZipuziwme1yW3dqSfCBvoT6h+6Cw5IGHnV8LvM2RiAeB/ fBi5MzZ5TnJWnxToB6f5D2gEFNDfKkKudhxNeqhI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Bj=C3=B8rn=20Mork?= , Jakub Kicinski Subject: [PATCH 4.19 013/211] usbnet: ignore endpoints with invalid wMaxPacketSize Date: Thu, 3 Oct 2019 17:51:19 +0200 Message-Id: <20191003154449.899499399@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154447.010950442@linuxfoundation.org> References: <20191003154447.010950442@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bjørn Mork [ Upstream commit 8d3d7c2029c1b360f1a6b0a2fca470b57eb575c0 ] Endpoints with zero wMaxPacketSize are not usable for transferring data. Ignore such endpoints when looking for valid in, out and status pipes, to make the drivers more robust against invalid and meaningless descriptors. The wMaxPacketSize of these endpoints are used for memory allocations and as divisors in many usbnet minidrivers. Avoiding zero is therefore critical. Signed-off-by: Bjørn Mork Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/usb/usbnet.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -112,6 +112,11 @@ int usbnet_get_endpoints(struct usbnet * int intr = 0; e = alt->endpoint + ep; + + /* ignore endpoints which cannot transfer data */ + if (!usb_endpoint_maxp(&e->desc)) + continue; + switch (e->desc.bmAttributes) { case USB_ENDPOINT_XFER_INT: if (!usb_endpoint_dir_in(&e->desc))