Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp528191pxb; Thu, 12 Aug 2021 23:57:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJympaRS++VBd7zwwMvakPhFRvY+YkYsv3c44Sce6SFK+LPBQnY3EIJVYlUiP36bpQ+VwNlS X-Received: by 2002:a92:6610:: with SMTP id a16mr747521ilc.71.1628837832471; Thu, 12 Aug 2021 23:57:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628837832; cv=none; d=google.com; s=arc-20160816; b=nvfweG/BSjir6+blCc/MR4jUs6YYTD2Z0JvZ6eYwVOtHQ6EllRTmRGgACrjXgRHHrj ixr5fD784Q/htRXoEbcgSKjZCbiVJ8ltw2yRhf3HcyOB0YzC49/7h1ozWzQZniTU9H8k bSXjWVHZvG/dIw0UleA9PgXTIpiyd2E53pCH1J5AJevNnWBxaMoTa02w3oV99D/n60Q2 mmW+pvVcx47lAjM8u8ebeJ+45S90aWClErO+v5a2Luyjq8HERexNBciGqyptF4hp5JZu 1Hf4jkVs3W3uTGxJZAC5/JuBKBJOUy8db+wv4KkDSdSVmPYt9U3hqm2O3tIPyM9iYEUw scQQ== 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:dkim-signature; bh=Y3jJbsSmEP+Mplxaw55RcX3FyGqEukXu8I8Kvben1/8=; b=LPD5dIwsl2arocjzEp0a5z+qgXdebDzadvTM6GZsZxjdGMpr6lkf/V5IK/MsBLyfUK atMzJLPhgVyYa7cKUZBhOqezFMdy6O3gaoQlr6AyaUclZwlegXdRc+FaJ1Ph5SfMJW7m SCIlqD8n4+WzM2OSh4i+S70GnKDm+VNR0ECnVukWFnrxREWW6pTFWnSJRZ+ZJsv0Jr8V WaKdzLNi1mrA0iDCJJdEBR5E7+p/kJ58Ak1FkEcqKgpP/GykWiEWe6J1UpBPojRPvmFJ UVEBusGnEb2IqNpBf/wfXsvelUMYK72/oxS2dviFz1wliVCat8zVdxvtQybxJUakJ1Kw vlMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Uu43ooe0; 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 q14si602194ilv.153.2021.08.12.23.57.01; Thu, 12 Aug 2021 23:57:12 -0700 (PDT) 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=Uu43ooe0; 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 S239135AbhHMG4H (ORCPT + 99 others); Fri, 13 Aug 2021 02:56:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:35740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239095AbhHMGzy (ORCPT ); Fri, 13 Aug 2021 02:55:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E034E60FC4; Fri, 13 Aug 2021 06:55:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628837728; bh=wC9KO+fAlbgCYi+D5FKUGu8oWyySC3HH67pt+slS538=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Uu43ooe02x+C4gbtmWB0TUMYHwyDVgpIxqWCgWi1BTEulAEm2vwfkbLuXrDgDMf1T 8Nm2sHvVv72T6QjepCIYufEj60Lyp1ntjh2K0zkQAQpoixZHbioWTK1CNz1M8IJDgs IIUYXPZA30dr3/OqQZw1NeG1lC+JUF8ojbBu46go= Date: Fri, 13 Aug 2021 08:55:25 +0200 From: Greg Kroah-Hartman To: Anirudh Rayabharam Cc: Valentina Manea , Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.org, syzbot+74d6ef051d3d2eacf428@syzkaller.appspotmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usbip: give back URBs for unsent unlink requests during cleanup Message-ID: References: <20210806164015.25263-1-mail@anirudhrb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 06, 2021 at 10:46:17PM +0530, Anirudh Rayabharam wrote: > On Fri, Aug 06, 2021 at 06:47:54PM +0200, Greg Kroah-Hartman wrote: > > On Fri, Aug 06, 2021 at 10:10:14PM +0530, Anirudh Rayabharam wrote: > > > In vhci_device_unlink_cleanup(), the URBs for unsent unlink requests are > > > not given back. This sometimes causes usb_kill_urb to wait indefinitely > > > for that urb to be given back. syzbot has reported a hung task issue [1] > > > for this. > > > > > > To fix this, give back the urbs corresponding to unsent unlink requests > > > (unlink_tx list) similar to how urbs corresponding to unanswered unlink > > > requests (unlink_rx list) are given back. Since the code is almost the > > > same, extract it into a new function and call it for both unlink_rx and > > > unlink_tx lists. > > > > > > [1]: https://syzkaller.appspot.com/bug?id=08f12df95ae7da69814e64eb5515d5a85ed06b76 > > > > > > Reported-by: syzbot+74d6ef051d3d2eacf428@syzkaller.appspotmail.com > > > Tested-by: syzbot+74d6ef051d3d2eacf428@syzkaller.appspotmail.com > > > Signed-off-by: Anirudh Rayabharam > > > --- > > > drivers/usb/usbip/vhci_hcd.c | 47 ++++++++++++++++++++++++++---------- > > > 1 file changed, 34 insertions(+), 13 deletions(-) > > > > > > diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c > > > index 4ba6bcdaa8e9..45f98aa12895 100644 > > > --- a/drivers/usb/usbip/vhci_hcd.c > > > +++ b/drivers/usb/usbip/vhci_hcd.c > > > @@ -945,7 +945,8 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) > > > return 0; > > > } > > > > > > -static void vhci_device_unlink_cleanup(struct vhci_device *vdev) > > > +static void __vhci_cleanup_unlink_list(struct vhci_device *vdev, > > > + struct list_head *unlink_list) > > > { > > > struct vhci_hcd *vhci_hcd = vdev_to_vhci_hcd(vdev); > > > struct usb_hcd *hcd = vhci_hcd_to_hcd(vhci_hcd); > > > @@ -953,23 +954,25 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev) > > > struct vhci_unlink *unlink, *tmp; > > > unsigned long flags; > > > > > > + if (unlink_list != &vdev->unlink_tx > > > + && unlink_list != &vdev->unlink_rx) { > > > + pr_err("Invalid list passed to __vhci_cleanup_unlink_list\n"); > > > + BUG(); > > > > Do not allow the system to crash, that is not ok. > > > > > + return; > > > > This call makes no sense as you just rebooted the machine :( > > > > Handle errors properly and recover from them and move on. A single tiny > > driver should not take down the whole system. > > The execution can reach only if there is a developer error and they passed > some random list in `unlink_list`. Why would a developer do that? As that is not the case in the kernel tree, no need to check for it. thanks, greg k-h