Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp136351lqc; Thu, 7 Mar 2024 12:35:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU01qk4ZFTu2b1nOHWeMygwm6l6aAPiw8Ed63fblBQFWvY/CNl0LnOFU9tq8VMLIgJVrojTj8bfd5jh+ylYcB/AqX011yS3N25nXUuU5w== X-Google-Smtp-Source: AGHT+IEUGLGS1/6ufB67uSDOo50qXABL2kSXGtXqNcMVu9MyVHaKM0YI/BH2nKu3Xv1AfeSsrEII X-Received: by 2002:a17:902:64cf:b0:1dd:61b4:ef89 with SMTP id y15-20020a17090264cf00b001dd61b4ef89mr1455362pli.41.1709843729597; Thu, 07 Mar 2024 12:35:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709843729; cv=pass; d=google.com; s=arc-20160816; b=JHoBGRezJAQQ9BeXW5FNyizJKSqiRxz2ZHoIfA09GF5Q4d7IC3H8BwtDBU+VNxZWsn rGYrittfc3TsOl85ONfnYGg3NlQlnKg07VV/3W1zXehFcCyfkCaVrYJUjYUnh8WSpGLQ /zUZWoIHdFQAcULZMwwuqlBNd/nFUVR4KIAt5wVGCRFVO44OPXW6MTsCxCS3Wvia1CKE gLthvh2w0VuQuUxqFHWr4e0Zvx0W1aW3qoPP13JrKCX4OSQTYumi/pgYhjDoJ8HLCGzM MEwpCJiNTkLz//g1HbHUY/gfxSGhvZEEdrfhO0rxgTJKOqKmOVBH7OF81natyASLmk5y imDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=Qi0y/IAm4KBXlEhdWBMGIKDxFsjG1fAKzJJYT4hhM3E=; fh=0CfSiooNnoIVqQ4jaPdTPJPNK4FAxVtlE1i2tMRoKn0=; b=s6sZEqlg9+lNK+v4UhlDGUTZpz1H1MLpm2+ob4TvX5TzBzMOf7IffSwUHVnEG0U9sW kAMDorsgNGmVosM4KZeDsYVcFJT09qBq71sJpwc1ygVxdtHhoL4l+jUb4+JJ/HEVeltD yyB1kTXtPEsbI3UoZnYMinxNVBLj1KfiKhwF9gcdWpezu3PdeBM4z0f3SYmoxCowcS9C u4LnUX1rZ+lMKbG8QLIxVLEG1AOj7MS2ZFnHzUziSwOARzn0rlyJ61nPEtmCQCvKS81H XwShKvcii9GuXu6kPDRUiT78/tKX788RUMrjuQebQRws4HxA2dZseeKWiFgjawGWkUlz 1JIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-kernel+bounces-96204-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96204-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n8-20020a170903110800b001dd10a1ee05si8291173plh.547.2024.03.07.12.35.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 12:35:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96204-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-kernel+bounces-96204-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96204-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4897A2813B3 for ; Thu, 7 Mar 2024 20:35:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00939137C5F; Thu, 7 Mar 2024 20:35:19 +0000 (UTC) Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by smtp.subspace.kernel.org (Postfix) with SMTP id 89BDA64AB6 for ; Thu, 7 Mar 2024 20:35:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.131.102.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709843718; cv=none; b=BhZTH9bJnzVb3L13kkHK+YsS/kKCuW5NpbPnsTloIeyRPKlt2oMpbfUa8KasLNPGa9hsGJUwsJV++kCqQEAixUgOBESEAwsr0GHS52HqJFFKUa4Ld5bjCT6hK3LYWrAugZbDBMuHgalAznTwNAp3D8Gq0/Uub4o3wsL1Oz6x+3Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709843718; c=relaxed/simple; bh=sljL2bAz7fGa4csXLlDQhqA6Biu86JZwj+HTMWssYf4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YcTYrrXDFS+XHTZD0Sa4vdy/+jDdgW9qzU2gn5PQo+oa7NTS+ZhWVBAgLleLNnUWYivCWeFs2TiSez+oGC8sX+G5GW8MawIfvXmuebXryQYb5bfLl69thQmRMm/XwbmmxilPv+nYkrtgbJp5Pyoo6aY/PBw6/mVF6uQ96Fs4qpU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu; spf=pass smtp.mailfrom=netrider.rowland.org; arc=none smtp.client-ip=192.131.102.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netrider.rowland.org Received: (qmail 232122 invoked by uid 1000); 7 Mar 2024 15:35:15 -0500 Date: Thu, 7 Mar 2024 15:35:15 -0500 From: Alan Stern To: Sam Sun Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, "xrivendell7@gmail.com" , Greg KH , hgajjar@de.adit-jv.com, quic_ugoswami@quicinc.com, stanley_chang@realtek.com, heikki.krogerus@linux.intel.com Subject: Re: [Bug] INFO: task hung in hub_activate Message-ID: <0afd0885-1650-47db-b2b3-43b597352e6b@rowland.harvard.edu> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Mar 04, 2024 at 08:10:02PM +0800, Sam Sun wrote: > Dear developers and maintainers, > > We encountered a task hung in function hub_activate(). It was reported > before by Syzbot several years ago > (https://groups.google.com/g/syzkaller-lts-bugs/c/_komEgHj03Y/m/rbcVKyLXBwAJ), > but no repro at that time. We have a C repro this time and kernel > config is attached to this email. The bug report is listed below. > If you have any questions, please contact us. > > Reported by Yue Sun > Reported by xingwei lee Yue: Can you try testing the patch below? Thanks. Alan Stern Index: usb-devel/drivers/usb/core/sysfs.c =================================================================== --- usb-devel.orig/drivers/usb/core/sysfs.c +++ usb-devel/drivers/usb/core/sysfs.c @@ -1168,14 +1168,24 @@ static ssize_t interface_authorized_stor { struct usb_interface *intf = to_usb_interface(dev); bool val; + struct kernfs_node *kn; if (kstrtobool(buf, &val) != 0) return -EINVAL; - if (val) + if (val) { usb_authorize_interface(intf); - else - usb_deauthorize_interface(intf); + } else { + /* + * Prevent deadlock if another process is concurrently + * trying to unregister intf or its parent device. + */ + kn = sysfs_break_active_protection(&dev->kobj, &attr->attr); + if (kn) { + usb_deauthorize_interface(intf); + sysfs_unbreak_active_protection(kn); + } + } return count; }