Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6549626ybx; Mon, 11 Nov 2019 10:47:12 -0800 (PST) X-Google-Smtp-Source: APXvYqy9cNTFctI9628NMmq6ChmLg/20YgbX4V5S2merk5isGxnTTqPkQA3nZBoVTapNcir+YqdL X-Received: by 2002:a50:ac1c:: with SMTP id v28mr28765259edc.156.1573498032721; Mon, 11 Nov 2019 10:47:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573498032; cv=none; d=google.com; s=arc-20160816; b=XcY1+TeWU8K5mAhNjSs7RT3dUTE5BKG4hdjj4fZEgu/8ULRrZTD1L14Sz+pX5s32IU 2D0eitzSdOntxLswv+MHmr/f+xoLwKLbQaWUgAVdDS6He3LqPl5upLFFSFwfNgr1u+uH UitSdmKOXNy+Xz/f3dwWnY6DPpGI/WFuwodQ3gazTtc7JQ9FIH0T3i4nfTmcx3PX+qU1 pYoOCPM+CAxhOBc2NLTB05ORbx/eUDS7FLWl79i56RUK8QLlxTqeStUlfrS9RWLk54tV WGbC0ng2ZGYWOyJoVY2u5Nmp5a7C2Cz0ezKymm5twVsgVUdhaHD6pXviJvWEM4gSOpB7 b2oQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fCsGfqgyOSKox/AAEGKFTE/BZUUzhTu5A4EAjASd8vM=; b=EO5SlbpMYCmaSEZeOLlpAzsNLIqazG6rw/HxMv/FYSycuBNXN58ZLgku+tLzotyiq8 Z9uJOPvASKeXMNcPmz0lR28pN9AuAqgHHVKaHw793LEOBnJ4KGyv2uMbaxyUNr7DPNCs CCGVhADLA2OG66j2bMWwf4JRsOhXcqMMNjPUVWSuNpFP2smwO6YGFyWb2ACYLg2Vq1Mm fz/iP1DEQ5RkJrxZSULddjFHuDfFvka5zkyQ+1g+axTOtOhZDfpDpylmPgBgz9EKsPum qDAJ1Y52JZpte7AQ7hDfXW95xq2zVdolKkJyTyK667OIfW3BqK5HMq56xrrco5AJG+BL UEnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jmqTGSOE; 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 bi3si11937254edb.331.2019.11.11.10.46.48; Mon, 11 Nov 2019 10:47:12 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=jmqTGSOE; 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 S1729458AbfKKSp3 (ORCPT + 99 others); Mon, 11 Nov 2019 13:45:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:37590 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729862AbfKKSp1 (ORCPT ); Mon, 11 Nov 2019 13:45:27 -0500 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 7F8B1204FD; Mon, 11 Nov 2019 18:45:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573497927; bh=MnK7ehj7+xV0kmId3+0WzFbw9Ncvx88UimjqEDk6eoY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jmqTGSOEsRuJy6lsyz12pLpYW6llVQ3PafaKwKjMKWJxDsmxT0x/leQfC7tqkTS2G hj3dDs5tbv5W1h1EGY7WiT4tu3IRh2cxdiz5kdmq1HxZhHWUhd+u4H+ZN/ZvsoagHj cVNVRsK/QMzRv3x4WUmwTJvVtAr4ztPXh2Wv2e6U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Sasha Levin Subject: [PATCH 4.19 098/125] USB: Skip endpoints with 0 maxpacket length Date: Mon, 11 Nov 2019 19:28:57 +0100 Message-Id: <20191111181452.927794058@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181438.945353076@linuxfoundation.org> References: <20191111181438.945353076@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: Alan Stern [ Upstream commit d482c7bb0541d19dea8bff437a9f3c5563b5b2d2 ] Endpoints with a maxpacket length of 0 are probably useless. They can't transfer any data, and it's not at all unlikely that an HCD will crash or hang when trying to handle an URB for such an endpoint. Currently the USB core does not check for endpoints having a maxpacket value of 0. This patch adds a check, printing a warning and skipping over any endpoints it catches. Now, the USB spec does not rule out endpoints having maxpacket = 0. But since they wouldn't have any practical use, there doesn't seem to be any good reason for us to accept them. Signed-off-by: Alan Stern Link: https://lore.kernel.org/r/Pine.LNX.4.44L0.1910281050420.1485-100000@iolanthe.rowland.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/core/config.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 921ad6998dec7..1eb72be75fb7b 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -348,6 +348,11 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, /* Validate the wMaxPacketSize field */ maxp = usb_endpoint_maxp(&endpoint->desc); + if (maxp == 0) { + dev_warn(ddev, "config %d interface %d altsetting %d endpoint 0x%X has wMaxPacketSize 0, skipping\n", + cfgno, inum, asnum, d->bEndpointAddress); + goto skip_to_next_endpoint_or_interface_descriptor; + } /* Find the highest legal maxpacket size for this endpoint */ i = 0; /* additional transactions per microframe */ -- 2.20.1