Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3971778pxb; Tue, 25 Jan 2022 00:19:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyIZwqqbNuCbT24kFWT7YvjqKH6m8NLFHtJfrB3XfKgdqXmXWvyjhMQr510TrqXLGprzCbv X-Received: by 2002:a05:6402:26d2:: with SMTP id x18mr7324878edd.147.1643098753095; Tue, 25 Jan 2022 00:19:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643098753; cv=none; d=google.com; s=arc-20160816; b=JIVJclN/5lDophUp8Xsn7/ru+j6cFBEjvC7Dj1rjYSe/ZaK+H+b8OUI908P++RQkJc LsU82ti1mzDm2xbsinZfLRVwpPpIzh5GE/PcdHFLctfgGHqoDiCKNi3dGnTolcfk/lSJ gwwdY+dz8yB+JJXTKx5DFn3g67FLDzhPG4cJWdMpJ5az72620zJ+k1km/w+uNFPPAEnu UC3QD6Kn4xoAMS8qcwzD7gisI3qMTv9zPiP18+szS7dsXzaubX7DZgDTbWFznYbtjbvD C8Y2LcrnzqA14ErWaMBTSnFQQkGfqwmYEPAVcNGjE6YynRMGlfvg9ttxrNXCobvQUJLP iz4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zIaiDpN6V/FsQHjbpi1B3cavefEpqJRpjGEqFpwILQ4=; b=f8kHMFXvBA1oWgwJqISpvhAIGfuNFR2cffyvUdsTpfOVqiUT6z0wb/jM0T0M7NvyFu P+pRbyHN7suD21zSA7dY8lCBO2xGGG9r/Qr426noa6WBPOWxY96C7PuYZG/NarNhSQfs u7KpUe07Piy9zBQ4RS4qt2qazAehFuxG8QebFGyeVhGD/YzNHwOqNeMUw1H67gd4oowH sR1WSa8+lMJyQR5UXClBlb8ykOIL2GDWXImTBX5+YzQGPyA3ro1JziF8wEuzMjGHRua4 dpIvAkskYtTUgqv0kqMrXTJkXHK8e6quEq9TKV/vQ/TiTvZNfxKpKTT2VLQAdqBmyS5j k8sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RBKeoU8f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r7si1185047edd.171.2022.01.25.00.18.48; Tue, 25 Jan 2022 00:19:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RBKeoU8f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S3413091AbiAYAiW (ORCPT + 99 others); Mon, 24 Jan 2022 19:38:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2363974AbiAXXq1 (ORCPT ); Mon, 24 Jan 2022 18:46:27 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC9E6C061A0F; Mon, 24 Jan 2022 11:12:57 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7A63E6090A; Mon, 24 Jan 2022 19:12:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 426DAC340E5; Mon, 24 Jan 2022 19:12:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051576; bh=4120A8VZL9g296UsoEXLhv0BwjBUN3MDhIHhMhZ5CP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RBKeoU8fApu7RDFmHsDH735UfsPLP1g2IsN22yU2DDk3eGcOWblZG2Te1V2kuPniv vuN2pNgrZq3+Cpipxj1gow6ymJGdwHhderOl6QSVsuw2+Qs8AGWTh80dflsVKm41J9 nbIfzikHPSrYH85O4vz6j2K1PTPJavDskMaG1UB4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan McDowell , Alan Stern Subject: [PATCH 4.19 002/239] USB: core: Fix bug in resuming hubs handling of wakeup requests Date: Mon, 24 Jan 2022 19:40:40 +0100 Message-Id: <20220124183943.194108428@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183943.102762895@linuxfoundation.org> References: <20220124183943.102762895@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alan Stern commit 0f663729bb4afc92a9986b66131ebd5b8a9254d1 upstream. Bugzilla #213839 reports a 7-port hub that doesn't work properly when devices are plugged into some of the ports; the kernel goes into an unending disconnect/reinitialize loop as shown in the bug report. This "7-port hub" comprises two four-port hubs with one plugged into the other; the failures occur when a device is plugged into one of the downstream hub's ports. (These hubs have other problems too. For example, they bill themselves as USB-2.0 compliant but they only run at full speed.) It turns out that the failures are caused by bugs in both the kernel and the hub. The hub's bug is that it reports a different bmAttributes value in its configuration descriptor following a remote wakeup (0xe0 before, 0xc0 after -- the wakeup-support bit has changed). The kernel's bug is inside the hub driver's resume handler. When hub_activate() sees that one of the hub's downstream ports got a wakeup request from a child device, it notes this fact by setting the corresponding bit in the hub->change_bits variable. But this variable is meant for connection changes, not wakeup events; setting it causes the driver to believe the downstream port has been disconnected and then connected again (in addition to having received a wakeup request). Because of this, the hub driver then tries to check whether the device currently plugged into the downstream port is the same as the device that had been attached there before. Normally this check succeeds and wakeup handling continues with no harm done (which is why the bug remained undetected until now). But with these dodgy hubs, the check fails because the config descriptor has changed. This causes the hub driver to reinitialize the child device, leading to the disconnect/reinitialize loop described in the bug report. The proper way to note reception of a downstream wakeup request is to set a bit in the hub->event_bits variable instead of hub->change_bits. That way the hub driver will realize that something has happened to the port but will not think the port and child device have been disconnected. This patch makes that change. Cc: Tested-by: Jonathan McDowell Signed-off-by: Alan Stern Link: https://lore.kernel.org/r/YdCw7nSfWYPKWQoD@rowland.harvard.edu Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1197,7 +1197,7 @@ static void hub_activate(struct usb_hub */ if (portchange || (hub_is_superspeed(hub->hdev) && port_resumed)) - set_bit(port1, hub->change_bits); + set_bit(port1, hub->event_bits); } else if (udev->persist_enabled) { #ifdef CONFIG_PM