Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp884066pxt; Fri, 6 Aug 2021 16:56:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPeY4iww+6QYt6I7TCbi4XupfYwPrGnm+lCrfbCWZpkiDF/2AyDMEXNLiEn7TnaC1VzHF0 X-Received: by 2002:a5d:85cf:: with SMTP id e15mr1361857ios.208.1628294177590; Fri, 06 Aug 2021 16:56:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1628294177; cv=pass; d=google.com; s=arc-20160816; b=Pd2CdjaXmlyaphn+pWAkI2qAFooMwnK1Z2+xKseywY/FyvJQ75VTJY30KJNoSAjonV zOGLeyKcZaqiD+D2Tgp/FBEGPLQyIRIhRFG1uD8mgDQ7QQDdroeL6ZJIPB8s9xkHsYy4 JbOClOHjuTPCvQ5zOK3ktALRRjObIY0E+dDXESzNL6c1thJg2E5CXgfpofQgA+NY2XrU CAWxPrP1DSDCND6QUuEUlbkjLE9pJ+hyiaVXyRZd9QSf4aRs4DnxwPYjrFFCCA6hPqUe vVqs768nEAK+RHc8X7PAcewRDp0RYq5hhqL5rd/se55qruHA1kqjaLPm9bWU0NXXHKgc 4urw== ARC-Message-Signature: i=2; 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=Mn1q6DOADEao/FpQAv/Cs8j4Ne3BhAG2jvQPfdsruQ0=; b=Dv74FfFp4Hn6QTK/zh5cJAAklM0X/RCyCi59VowjUVMsJadqIg+KlmP59L/3K3dTlI dLT38N5AfU4O9+GI5qcy3MK46DwBtr0hk1q0d+FR9rzRuHdIRQ01TsGY8JclKd1hIQa4 TEUl5xq00jv9UTHdlmdPsayPIFlT7bBaAD7vaB41QBLbLz1nWmR2PU3zrUQTXdzGVCWX N0uXBWQPAhdnZsV+q/q39PoBCVoXE4TcK75xcEYTQcSGP5McCzwcj+jA3JnfVQVLrG9n txqwUB8DluQ7LNDaSG/uBOgJkZDtJSO/WvvfHvGxfEu9EisNGaaF4fRbDiZxMNbOlqDk rypg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@anirudhrb.com header.s=zoho header.b=wylVa7iX; arc=pass (i=1 spf=pass spfdomain=anirudhrb.com dkim=pass dkdomain=anirudhrb.com dmarc=pass fromdomain=anirudhrb.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 c126si3556033iof.49.2021.08.06.16.56.06; Fri, 06 Aug 2021 16:56:17 -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=@anirudhrb.com header.s=zoho header.b=wylVa7iX; arc=pass (i=1 spf=pass spfdomain=anirudhrb.com dkim=pass dkdomain=anirudhrb.com dmarc=pass fromdomain=anirudhrb.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 S240700AbhHFRQs (ORCPT + 99 others); Fri, 6 Aug 2021 13:16:48 -0400 Received: from sender4-of-o53.zoho.com ([136.143.188.53]:21384 "EHLO sender4-of-o53.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbhHFRQr (ORCPT ); Fri, 6 Aug 2021 13:16:47 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1628270186; cv=none; d=zohomail.com; s=zohoarc; b=MGYtQv0N2P0s4WpiI/7SCa5cluFDHsRicj9t8o0lEPYl7ybY21fLcNmv/cZweNleSYwhzKSyFP3V31E0wivExUUng5HlsYr9xuxhWToOTVqAMxktDN5ihJRPzPU0l666KpLQTiSh6s/DFjgadI0EdMv0rc5w+9yCcN7w8VF7i9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628270186; h=Content-Type:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Mn1q6DOADEao/FpQAv/Cs8j4Ne3BhAG2jvQPfdsruQ0=; b=UD3tLECcrs4Eqdk6YG5M4dzkAD7PI5J8Em3RX7qKPvXXgrg36xHXBaCAUuIUAhijs8CwO71gWcPjkqHkARxxUmOr5v2V1VXqtgtdByw65e2hGGvgpHILS4IhpX2VYfFlvDJyER8SG0Uh30YF/7/URKZUEaOiJmIvu3bgMO9VE4g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=anirudhrb.com; spf=pass smtp.mailfrom=mail@anirudhrb.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1628270186; s=zoho; d=anirudhrb.com; i=mail@anirudhrb.com; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type:In-Reply-To; bh=Mn1q6DOADEao/FpQAv/Cs8j4Ne3BhAG2jvQPfdsruQ0=; b=wylVa7iXI5evEarzbIu/ZfcEs+YR148aez8XrDpaDfH4SI+OQDrCNc9HK6gXL4ws 0fwofMCKNEgaaaCjwsNOtXbIjkp+eGuhkpcXbVZSF+oXf6m95aXUewQI+FFgMSLZ7Ju Ywb2N0xdQfUAoIN9+7GVHb/RWOJHn2oQpdEkits0= Received: from anirudhrb.com (106.51.104.154 [106.51.104.154]) by mx.zohomail.com with SMTPS id 1628270183513352.4266722757876; Fri, 6 Aug 2021 10:16:23 -0700 (PDT) Date: Fri, 6 Aug 2021 22:46:17 +0530 From: Anirudh Rayabharam To: Greg Kroah-Hartman 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: X-ZohoMailClient: External Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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`. So, BUG() here crashes the kernel and draws attention to this fact. Is WARN() a better option here? There is no way to recover from this and continue with the rest of the function. Either we WARN()/BUG() or we return silently. Thanks! - Anirudh.