Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5025725ybl; Tue, 14 Jan 2020 02:11:30 -0800 (PST) X-Google-Smtp-Source: APXvYqyP2f5LYuudXUUi7Z8X3EGeqiOcUBIJnsarN7BBDK1moeYe6q94VLhzUDXyneb2k/FxtjJN X-Received: by 2002:a9d:5888:: with SMTP id x8mr15519266otg.361.1578996690494; Tue, 14 Jan 2020 02:11:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578996690; cv=none; d=google.com; s=arc-20160816; b=JsLgrlr2q7Hu0qLIsuciV+su7H0AbWHTuC3DAGAtbuRv7dR04tcvW6JMYV7f7gyaHz 7aISGBSm4edo39Sdpr7CRiC9AJSHlsag/Ef0gRlVYkI1D98YYlnO6I2IUPIi59p4Ejxa D+7W2fXISnMMm2kCQ/FSDk54DqAuR93DSy854sEbZoe5v+dBqne7ntZvRh43YxHHX5nL KbReiJoYz9rRc4dQzb6LDBoCSNt+wksPlBuv00txfNU8XosYtRfya/zpxBs76rF6rCkA /eIgaG/ASbfTbdHScANKuWBUtKF5VpsGLlzGZdiNF0SmLCODtFt3DDl1hPNqP8ojyGKf uLIw== 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=Jnjq6Y3F3KVV9+jOwryjDmJ2U9MXtG7htn+UctFwwfE=; b=TNQ83LHAMhMmxb6BHcxk4V8EOPvUSYC3zFcsUhh4e47OY9Xu1P3XLtF1PLJuTA9OlR VwS2/VRzcmT/P2+VP4f+V4zQetOKyV+kr0Vs6iq1xX+ouEtZxOxMibBmNEUQggz256EQ JzOZV3Gav41D0KIN9n46vG/08KUxgO0O+7KbWK/pkPqutwsH+LBkiw/fDELg7JypoWEy 46q2qXOFZETku+GVPNz9XzUdlrrSVJn8pppevtfE0c4mKV7o07PC4qXBkOKWia+xImjF yMIP3AprpQwxFiFwVmqIu+dCeoHu0tYE8dx5mzzyCektuN9Ajtv52OQL8eZpF+eqXdAa Kx8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qT9ZOd+w; 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 i13si8184621otc.228.2020.01.14.02.11.19; Tue, 14 Jan 2020 02:11:30 -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=qT9ZOd+w; 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 S1731657AbgANKKX (ORCPT + 99 others); Tue, 14 Jan 2020 05:10:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:44052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729447AbgANKKU (ORCPT ); Tue, 14 Jan 2020 05:10:20 -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 3C47224676; Tue, 14 Jan 2020 10:10:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578996619; bh=+PI48K9XTvgjwsMAYb2zfC9iKKt9NZ6/WaU3LZy+OyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qT9ZOd+wf8mhLszf5Ur/zsM6adobQE3SMHRvYDRsTxf4zU0jdry4qfOMBSb3ktqD9 fuMYZPA4lsl3euMDe/jyc/ajfsKwkjHbbEF9oSSy6ZUBRwCr1eIRIvpEeaqjv1s7eq uuP8EWfbE+RoS2TDMsv8YP62kugM2S+N327LNsME= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Laurent Pinchart , Roger Whittaker Subject: [PATCH 4.14 35/39] USB: Fix: Dont skip endpoint descriptors with maxpacket=0 Date: Tue, 14 Jan 2020 11:02:09 +0100 Message-Id: <20200114094346.366822834@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200114094336.210038037@linuxfoundation.org> References: <20200114094336.210038037@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 commit 2548288b4fb059b2da9ceada172ef763077e8a59 upstream. It turns out that even though endpoints with a maxpacket length of 0 aren't useful for data transfer, the descriptors do serve other purposes. In particular, skipping them will also skip over other class-specific descriptors for classes such as UVC. This unexpected side effect has caused some UVC cameras to stop working. In addition, the USB spec requires that when isochronous endpoint descriptors are present in an interface's altsetting 0 (which is true on some devices), the maxpacket size _must_ be set to 0. Warning about such things seems like a bad idea. This patch updates an earlier commit which would log a warning and skip these endpoint descriptors. Now we only log a warning, and we don't even do that for isochronous endpoints in altsetting 0. We don't need to worry about preventing endpoints with maxpacket = 0 from ever being used for data transfers; usb_submit_urb() already checks for this. Reported-and-tested-by: Roger Whittaker Fixes: d482c7bb0541 ("USB: Skip endpoints with 0 maxpacket length") Signed-off-by: Alan Stern CC: Laurent Pinchart Link: https://marc.info/?l=linux-usb&m=157790377329882&w=2 Link: https://lore.kernel.org/r/Pine.LNX.4.44L0.2001061040270.1514-100000@iolanthe.rowland.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/config.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -392,12 +392,16 @@ static int usb_parse_endpoint(struct dev endpoint->desc.wMaxPacketSize = cpu_to_le16(8); } - /* Validate the wMaxPacketSize field */ + /* + * Validate the wMaxPacketSize field. + * Some devices have isochronous endpoints in altsetting 0; + * the USB-2 spec requires such endpoints to have wMaxPacketSize = 0 + * (see the end of section 5.6.3), so don't warn about them. + */ 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", + if (maxp == 0 && !(usb_endpoint_xfer_isoc(d) && asnum == 0)) { + dev_warn(ddev, "config %d interface %d altsetting %d endpoint 0x%X has invalid wMaxPacketSize 0\n", cfgno, inum, asnum, d->bEndpointAddress); - goto skip_to_next_endpoint_or_interface_descriptor; } /* Find the highest legal maxpacket size for this endpoint */