Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1289214pxb; Fri, 21 Jan 2022 14:28:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxR1/zHpX/A+eaKw1pU4iaIy2rNhTg++lEdld6d95KzRVcyTeH7BIdca95X19dds85nKfWC X-Received: by 2002:a05:6a00:139c:b0:4c1:e1cd:21c3 with SMTP id t28-20020a056a00139c00b004c1e1cd21c3mr5665749pfg.72.1642804114080; Fri, 21 Jan 2022 14:28:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642804114; cv=none; d=google.com; s=arc-20160816; b=rNXIUcteSXRBqtJhs2RLizgX2x/1VndznXcO3G8HWKuQWPUs4rByijH67Vdfv6ZTYv mdzppBu4BkwNwqozvlmNzo8urhsN0Fl1GHchIh5njU72RNivBoHlW69MdHy1E0/sSNPv 97ggKNxcYJmW7svX/M7EeUV7XO1GRT32ZSIcplpVRz6KuntJdUeXididJlm7DEV8NICR zPHYmmhGuI5vsT5S6GMIlw/cMYKtSgsd/hVCoEwYRjqvWB4B90Amne8VpxXYuoh13Oxn LAoslWDImB1DCDZQVKH1Kua1dNMHikKuoRfLDpEDVDbVpLGx6yrJaDzz5fcVINnnfQMN 274A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=zi5XRtULDTzfxiJwoZMEOszUjFvXeTcJ8UXNjCXi148=; b=ZN9u2mQkv4rMcUoVgbOlkhrAm/Y2BYucU/ZiXlDJ2/bT4boPiD59MXCBzhl+bDfn2P zm6jGAuQiAEzNqSiI6gkCyI0SBuAz/S3CVCAbvafUAj+uIaYUasVw2d+6/DV8sj/Jh6V qiCX/yDBtXY2d4qHqZQF49bLNRLukAP2JS5SP2ZDXI1Drc2sgGSG8/eVt5mnYolSp36y 5fYd4Jz0pbhNHy8ZhYFpzPXt0Q7jxJK+o5XIaCeRXpLgJyhlncjMYR3g1wjx1esRwA0n cqxxmeVMQnSyyBgMW/Yil7HeggLZ+9AAT5KvKrKesNG7XP+PLM6DZfB0Us5ZUUJbXGIr 1rPQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x13si10170624pge.184.2022.01.21.14.28.21; Fri, 21 Jan 2022 14:28:34 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230510AbiATR2u (ORCPT + 99 others); Thu, 20 Jan 2022 12:28:50 -0500 Received: from netrider.rowland.org ([192.131.102.5]:33033 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S231535AbiATR2n (ORCPT ); Thu, 20 Jan 2022 12:28:43 -0500 Received: (qmail 157157 invoked by uid 1000); 20 Jan 2022 12:28:42 -0500 Date: Thu, 20 Jan 2022 12:28:42 -0500 From: Alan Stern To: syzbot Cc: gregkh@linuxfoundation.org, hdanton@sina.com, johan@kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, paskripkin@gmail.com, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] INFO: task hung in hub_port_init (2) Message-ID: References: <20220120080020.2619-1-hdanton@sina.com> <000000000000836a4805d5ff0b2b@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000000000000836a4805d5ff0b2b@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 20, 2022 at 12:11:10AM -0800, syzbot wrote: > Hello, > > syzbot has tested the proposed patch and the reproducer did not trigger any issue: > > Reported-and-tested-by: syzbot+76629376e06e2c2ad626@syzkaller.appspotmail.com > > Tested on: > > commit: 6f59bc24 Add linux-next specific files for 20220118 > git tree: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git > kernel config: https://syzkaller.appspot.com/x/.config?x=94e8da4df9ab6319 > dashboard link: https://syzkaller.appspot.com/bug?extid=76629376e06e2c2ad626 > compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2 > patch: https://syzkaller.appspot.com/x/patch.diff?x=101ba7efb00000 > > Note: testing is done by a robot and is best-effort only. Attempted fix. Alan Stern #syz test: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/ 6f59bc24 Index: usb-devel/drivers/usb/core/hcd.c =================================================================== --- usb-devel.orig/drivers/usb/core/hcd.c +++ usb-devel/drivers/usb/core/hcd.c @@ -1563,6 +1563,12 @@ int usb_hcd_submit_urb (struct urb *urb, urb->hcpriv = NULL; INIT_LIST_HEAD(&urb->urb_list); atomic_dec(&urb->use_count); + /* + * Order the write of urb->use_count above against the read of + * urb->reject below. Pairs with the memory barriers in + * usb_kill_urb() and usb_poison_urb(). + */ + smp_mb__after_atomic(); atomic_dec(&urb->dev->urbnum); if (atomic_read(&urb->reject)) wake_up(&usb_kill_urb_queue); @@ -1665,6 +1671,13 @@ static void __usb_hcd_giveback_urb(struc usb_anchor_resume_wakeups(anchor); atomic_dec(&urb->use_count); + /* + * Order the write of urb->use_count above against the read of + * urb->reject below. Pairs with the memory barriers in + * usb_kill_urb() and usb_poison_urb(). + */ + smp_mb__after_atomic(); + if (unlikely(atomic_read(&urb->reject))) wake_up(&usb_kill_urb_queue); usb_put_urb(urb); Index: usb-devel/drivers/usb/core/urb.c =================================================================== --- usb-devel.orig/drivers/usb/core/urb.c +++ usb-devel/drivers/usb/core/urb.c @@ -715,6 +715,12 @@ void usb_kill_urb(struct urb *urb) if (!(urb && urb->dev && urb->ep)) return; atomic_inc(&urb->reject); + /* + * Order the write of urb->reject above against the read of + * urb->use_count below. Pairs with the barriers in + * __usb_hcd_giveback_urb() and usb_hcd_submit_urb(). + */ + smp_mb__after_atomic(); usb_hcd_unlink_urb(urb, -ENOENT); wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); @@ -756,6 +762,12 @@ void usb_poison_urb(struct urb *urb) if (!urb) return; atomic_inc(&urb->reject); + /* + * Order the write of urb->reject above against the read of + * urb->use_count below. Pairs with the barriers in + * __usb_hcd_giveback_urb() and usb_hcd_submit_urb(). + */ + smp_mb__after_atomic(); if (!urb->dev || !urb->ep) return;