Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1538986pxb; Thu, 16 Sep 2021 09:30:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymYvNcoOV6OKBcpFmSppdfcJJCfqWZebefsfxYoIwd7j7Nj0i3Cft/VgK0DWLsCA8PSu3P X-Received: by 2002:a92:d491:: with SMTP id p17mr4723283ilg.107.1631809808138; Thu, 16 Sep 2021 09:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631809808; cv=none; d=google.com; s=arc-20160816; b=mOFOrmphCY0Ug6aOLkBvKoGp2rcv6JO+weQRu3VKgvp3cTffbwTIz897hC5ArXz4x5 i9SyCpyKUFMoKV2Q+abqIA8HfB0w1ETiPVurFKuaGvQ75oiwEI0+Iziq5ZcpdoPos3it LEk4hOEqEeOW7INjck3pxX6SaoO3EqB7bGP0qGBHbmaQ3w1gWdwqnj/WAL1ODTs7WP/+ CyvuFxWRaivAwF+aN4ckbQiz/e8XjX1dkyaHfYx4uM2FI+6vHqVGm/jIEFc0OXQ02qZc q4jMxP089BN1sbph84BwpCKgmazr9/Xwa7T9GTVLVKPQV6eZjnQfycGOl3hKxC2MScqY J6uA== 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=Fx8T8mJ+YCqXO2aPBwNyz/VBww6hrH01Hn931GOqJow=; b=rSztsIK7UskmYhLp547AaBuQOul8Qjqs+LLD8vj3TrKQbUfIo5ftk1CC3ykzb9eepm NSPIHWYqPuCeT9q21t2APJ7HIIIyUKJepaXYNOAQ2tgGeK1kCvA1aPX2hN0NzDfEuu2a Yv0u8ZSNAN12/DwGMA2hk6VHPRB73yo//P4Bn9RrPtBecLn9FkcGs5MF4XGHPkZwcTy8 A1wsmOO3ROJqyVZK3hn2heJG7bzv8kTV+0i+s0Mg1pfMfiAKuI7cCguFPbtAxJRDMuqR PAfZ7NSoZ8/n+F/oxfJaCSyIqdtUtrZ7UouK/WGsZ44tktcALkbz4QU1pfbiJV67Bgq4 AHZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zedpTxLt; 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 c18si3700329iod.38.2021.09.16.09.29.56; Thu, 16 Sep 2021 09:30:08 -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=zedpTxLt; 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 S243062AbhIPQ35 (ORCPT + 99 others); Thu, 16 Sep 2021 12:29:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:60152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235820AbhIPQUi (ORCPT ); Thu, 16 Sep 2021 12:20:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 048F861401; Thu, 16 Sep 2021 16:14:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808874; bh=7mmHLthpFheFiPyehS8KBoLv55k9vZhDiW0Qcdq4vcI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zedpTxLthfYgurv+tDL1tVlm+yHgkDH9QCyVlenN1G88u9iGSgy09ID+pPFhdghIc aU5iJnpLHMeoIskjcgvcurwGoRAmy5BoZmnXhZ116Y0uDA4kcgMVKraj9OZt1PK7gV +5umyGs47tsknxR5/Y+3UHlxVa68ZviuUFWhwlx8= 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.10 255/306] usbip: give back URBs for unsent unlink requests during cleanup Date: Thu, 16 Sep 2021 18:00:00 +0200 Message-Id: <20210916155802.762327694@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@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 4ba6bcdaa8e9..190bd3d1c1f0 100644 --- a/drivers/usb/usbip/vhci_hcd.c +++ b/drivers/usb/usbip/vhci_hcd.c @@ -957,8 +957,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