Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2350189pxb; Mon, 20 Sep 2021 19:44:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxal9e6ukqypiIArIOmMgMJKvsTVDYDmN/S+XW+jE/oD5tyvAJ+c58oYxGXcOju+WmQdtwN X-Received: by 2002:a5d:9d59:: with SMTP id k25mr8577246iok.70.1632192298736; Mon, 20 Sep 2021 19:44:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192298; cv=none; d=google.com; s=arc-20160816; b=DSSvhl4R3wnKakC/P1aNIjXBA7NWqVuGwMSOwQiYItGFshEcgNKYh4RVfdzqmA+eBM 7WeYNamkmmYQhhiFh+gCLZ8Ou6yZoGlWV6FInSmf/2YvwZfI8RRINod1KHxUmdUNSdvo udcDxrUww5sbh5S+/NkIcBWoZtyrJS5QDEGpAYPfvyFPmHcvh0Stm4C75tFic+Da7KGK WbG8hwt1T/St4bu/kk5X2GoJ0Qk9/1KSEttFONbEI+hXjbVWSfl02QNHL8ANlFcVat9n whziCep67LPJuJEEaQ0aXeuS6VRkx4kPbLQBo/LKCKzQRi7vwIkjzdfI4xuh1UjOlYvE 4KiA== 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=lMhei/mEIVsztETJ2qslml9K2idbSBkfdLGFZMvva7I=; b=ihYoVUNQpZmtML+iI7e6aAcCltkRF8c314kD14DJt4gwDONeKxAO0asgOSDcjsIViy ec6zgUXO5mHYHAB3PYK4lPhli94KUkXKzR83PA2NAHDpttjxdS8QdOUHtSeiQeqngQl3 lYHsHmwr05pz1eMTzdndgYaUjWfhbYfwb0ohYTcpaSw2MiWYjP2uvaomUfHe//DoDNUz ip+ybkLVMV/bex3tnijbamcV0HXVaaSoNUReqFKVTNiJs3oj2rXPn2FlrC86toSX2EFM LL96hsUcLFb9Lv7c6wEfEFQR1VPT8aSw/SXIPpkpObZQBZ1muBh+OcA1nG2Q/WidrFxl pfHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v1fFRtFd; 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 l7si2244220ioh.59.2021.09.20.19.44.47; Mon, 20 Sep 2021 19:44:58 -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=v1fFRtFd; 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 S1351967AbhITSXP (ORCPT + 99 others); Mon, 20 Sep 2021 14:23:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:40192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358881AbhITSQO (ORCPT ); Mon, 20 Sep 2021 14:16:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 06320613D5; Mon, 20 Sep 2021 17:21:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158514; bh=wN6vSEPhPLmzIulhSS4Va0sPao8QvE+7Z2WVoHmIeuc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v1fFRtFdi+BaR8fBIvkH0aFqLNO8883PQK2RuJsRr3URDym3k8Z1Wh2Rn6U5WPFw3 T0jK3eBTUEZ5pHijCw0iQT74ouThtUMcPeWNfDaN6/dicsyHr3TX+ZOmp6rrIbO6L8 6pnuz6kgBUdYd1xJ/KoMNkTAtp6PnDtst9+tS6fY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+74d6ef051d3d2eacf428@syzkaller.appspotmail.com, Shuah Khan , Anirudh Rayabharam , Sasha Levin Subject: [PATCH 5.4 159/260] usbip: give back URBs for unsent unlink requests during cleanup Date: Mon, 20 Sep 2021 18:42:57 +0200 Message-Id: <20210920163936.501956170@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@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: Anirudh Rayabharam [ Upstream commit 258c81b341c8025d79073ce2d6ce19dcdc7d10d2 ] 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. [1]: https://syzkaller.appspot.com/bug?id=08f12df95ae7da69814e64eb5515d5a85ed06b76 Reported-by: syzbot+74d6ef051d3d2eacf428@syzkaller.appspotmail.com Tested-by: syzbot+74d6ef051d3d2eacf428@syzkaller.appspotmail.com Reviewed-by: Shuah Khan Signed-off-by: Anirudh Rayabharam Link: https://lore.kernel.org/r/20210820190122.16379-2-mail@anirudhrb.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/usbip/vhci_hcd.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c index 98636fbf7188..46a46cde2070 100644 --- a/drivers/usb/usbip/vhci_hcd.c +++ b/drivers/usb/usbip/vhci_hcd.c @@ -952,8 +952,32 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev) spin_lock(&vdev->priv_lock); list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) { + struct urb *urb; + + /* give back urb of unsent unlink request */ pr_info("unlink cleanup tx %lu\n", unlink->unlink_seqnum); + + urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum); + if (!urb) { + list_del(&unlink->list); + kfree(unlink); + continue; + } + + urb->status = -ENODEV; + + usb_hcd_unlink_urb_from_ep(hcd, urb); + list_del(&unlink->list); + + spin_unlock(&vdev->priv_lock); + spin_unlock_irqrestore(&vhci->lock, flags); + + usb_hcd_giveback_urb(hcd, urb, urb->status); + + spin_lock_irqsave(&vhci->lock, flags); + spin_lock(&vdev->priv_lock); + kfree(unlink); } -- 2.30.2