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=unavailable 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 6C7C2C10F14 for ; Thu, 3 Oct 2019 16:01:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 359DE215EA for ; Thu, 3 Oct 2019 16:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570118507; bh=svnBraEINLjsPtQxZ9LCLJLTnzolJHZG7uWWGddNu6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Mc6jU1k+/RYIVg1OjDjjr3wJ6AuT/P9gvE/GBcIvwTvwCUU0fauCi6ILqNZpLwFuH NhR7cMBZWSz2x2aIIJ76Je5LBguRAX4YKA8vflUfARKgZyZy3QQPy+Yz3xUEz9+kZT Qg2BT4QS/cE7l9kshOZk5BOlxVoZaOHSb+AokjCw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731883AbfJCQBm (ORCPT ); Thu, 3 Oct 2019 12:01:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:46142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731880AbfJCQBl (ORCPT ); Thu, 3 Oct 2019 12:01:41 -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 E138420700; Thu, 3 Oct 2019 16:01:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570118501; bh=svnBraEINLjsPtQxZ9LCLJLTnzolJHZG7uWWGddNu6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gHNai6HmLua8Jzx0IYm9NxMcaT1QXJ11hCA/SQoPI9ybbH4Zf/ie6KahvcaebRBXe oHRNdj5CfzA/aiOU9Bky6QkqzBOWxZm2lnVZHQBe3W/fF7B+RT3OlefuSsaPZE5yNy 6hA0JkeVDOJt3Yo3HpviUH6P272JFDGGzqS4L/hg= 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.9 032/129] usbnet: ignore endpoints with invalid wMaxPacketSize Date: Thu, 3 Oct 2019 17:52:35 +0200 Message-Id: <20191003154333.680194033@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154318.081116689@linuxfoundation.org> References: <20191003154318.081116689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -114,6 +114,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))