Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp712570ybl; Thu, 12 Dec 2019 03:46:45 -0800 (PST) X-Google-Smtp-Source: APXvYqytOCe6F+X4jJT/6MwsUTCEapWKaWeCg6VwYkBNGogKDDnkI3zGJq5p57SnPbMrWOyVB+zi X-Received: by 2002:a9d:d0b:: with SMTP id 11mr7954623oti.287.1576151205819; Thu, 12 Dec 2019 03:46:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576151205; cv=none; d=google.com; s=arc-20160816; b=WglaNRqORbZmWWgabONjg9HUbyN2uVlY/PrFNOnsN1RB+hsBUgXzrjKHaqR56IsHmz TO6jGzL7iYXLx4F66mhBhB+PKBuFLd4Dnq5J1ed2N15sJt4tglFrk7Qo0CINfNOKDs0W uHbI98Z6+15foP17w54Se9i76HogmTXDCGLHMi0DnPBSP41fJadF15xT9eDu88L6Noid lUGQX5W44tM1do9W2JCROaxIBq21PQ5VYqEZ+v0w/k/VAZFRNYOIj7tGKhrUBIMtEZAg CPjJDAo0aBYJQ9ezTMvZqDcVoM3SOfpTkfuhGbXqyEis41VgGeX1rowvtd0SOZptIS46 uKzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=4yy/mfyeqp/ssdzr+XsQXJ2B1nLiIhHBkihSE4FidX0=; b=ZIflTopCkIa+XSz584EedSkMBUM3L0+xVGbSB0Y+5k0TO6fRKM9+MMcPhT7BzPrp8P SipEjozDoZT+Y1/vn2plypR317CN7h8eP4A26DOhxGZ86TJrvggt6w3qQ60dOpnqX3Jw dznuO0NtWd7OxFh5B8gS+dcd9mHwJVqZbLQMqR5RB+0KfLSDBpkHq1uwTnMBfTKbXlkp chkeRzZLUX0HQn1fg6KlHIbM4ni79SEW8zjVYTxbPz84eddYT1/Po92AS6+Ft8EThm7q KLtk78FGVWK3ZbzIzsNxyehtBt095PEc1BlTfP3L/MfcfuZaMpL4egSmQI2o1UoDFZPF +iRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Dol4+ATh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13si3029787otr.297.2019.12.12.03.46.29; Thu, 12 Dec 2019 03:46:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Dol4+ATh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729059AbfLLLpq (ORCPT + 99 others); Thu, 12 Dec 2019 06:45:46 -0500 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:33957 "EHLO wout3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726492AbfLLLpq (ORCPT ); Thu, 12 Dec 2019 06:45:46 -0500 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 87F22730; Thu, 12 Dec 2019 06:45:44 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Thu, 12 Dec 2019 06:45:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=4yy/mf yeqp/ssdzr+XsQXJ2B1nLiIhHBkihSE4FidX0=; b=Dol4+AThWANER7tsxzPEIX NW95ZDS1On6p0s9gqy4Gl8G1mZiTbgVO6rzJWXH2ZalqRSYzwcnLkPMI4wT2MiiS E/GcCfD3vAEX1/uJwYBOUKJVzdZzcAUX0h6Zqw27/XU9zsTQFLjNQ1YUQ6Sjil3g Q/8xsSUdABrDLbSF9gCUmCQVcXzBRxkV8ydh1idwRhihFQXhwqavB1CQtQ41Om/j t0czsZLMEa//0nvlthshpnPvOxYI4u8L+MGMHKMwfG64YJJMI0D+5Hlbnv/V7NVC ijbmm7osCWB4Xgg+ugPxTmgDdU0RykE87CgKy6DvBmVRWRlDKVp5q6mNuCx0Tc4g == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudeljedgfeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehgtderredttdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucfkphepledurdeihedrfeegrdef feenucfrrghrrghmpehmrghilhhfrhhomhepmhgrrhhmrghrvghksehinhhvihhsihgslh gvthhhihhnghhslhgrsgdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from mail-itl (ip5b412221.dynamic.kabel-deutschland.de [91.65.34.33]) by mail.messagingengine.com (Postfix) with ESMTPA id F267C3060130; Thu, 12 Dec 2019 06:45:42 -0500 (EST) Date: Thu, 12 Dec 2019 12:45:40 +0100 From: Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= To: Suwan Kim Cc: shuah@kernel.org, valentina.manea.m@gmail.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 2/2] usbip: Fix error path of vhci_recv_ret_submit() Message-ID: <20191212114540.GV11116@mail-itl> References: <20191212052841.6734-1-suwan.kim027@gmail.com> <20191212052841.6734-3-suwan.kim027@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="CMEQapY8OuP5ao1l" Content-Disposition: inline In-Reply-To: <20191212052841.6734-3-suwan.kim027@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --CMEQapY8OuP5ao1l Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH 2/2] usbip: Fix error path of vhci_recv_ret_submit() On Thu, Dec 12, 2019 at 02:28:41PM +0900, Suwan Kim wrote: > If a transaction error happens in vhci_recv_ret_submit(), event > handler closes connection and changes port status to kick hub_event. > Then hub tries to flush the endpoint URBs, but that causes infinite > loop between usb_hub_flush_endpoint() and vhci_urb_dequeue() because > "vhci_priv" in vhci_urb_dequeue() was already released by > vhci_recv_ret_submit() before a transmission error occurred. Thus, > vhci_urb_dequeue() terminates early and usb_hub_flush_endpoint() > continuously calls vhci_urb_dequeue(). >=20 > The root cause of this issue is that vhci_recv_ret_submit() > terminates early without giving back URB when transaction error > occurs in vhci_recv_ret_submit(). That causes the error URB to still > be linked at endpoint list without =E2=80=9Cvhci_priv". >=20 > So, in the case of trasnaction error in vhci_recv_ret_submit(), ^^^ typo > unlink URB from the endpoint, insert proper error code in > urb->status and give back URB. >=20 > Reported-by: Marek Marczykowski-G=C3=B3recki > Signed-off-by: Suwan Kim Tested-by: Marek Marczykowski-G=C3=B3recki > --- > drivers/usb/usbip/vhci_rx.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) >=20 > diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c > index 33f8972ba842..dc26acad6baf 100644 > --- a/drivers/usb/usbip/vhci_rx.c > +++ b/drivers/usb/usbip/vhci_rx.c > @@ -77,16 +77,21 @@ static void vhci_recv_ret_submit(struct vhci_device *= vdev, > usbip_pack_pdu(pdu, urb, USBIP_RET_SUBMIT, 0); > =20 > /* recv transfer buffer */ > - if (usbip_recv_xbuff(ud, urb) < 0) > - return; > + if (usbip_recv_xbuff(ud, urb) < 0) { > + urb->status =3D -EPIPE; > + goto error; > + } > =20 > /* recv iso_packet_descriptor */ > - if (usbip_recv_iso(ud, urb) < 0) > - return; > + if (usbip_recv_iso(ud, urb) < 0) { > + urb->status =3D -EPIPE; > + goto error; > + } > =20 > /* restore the padding in iso packets */ > usbip_pad_iso(ud, urb); > =20 > +error: > if (usbip_dbg_flag_vhci_rx) > usbip_dump_urb(urb); > =20 --=20 Best Regards, Marek Marczykowski-G=C3=B3recki Invisible Things Lab A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? --CMEQapY8OuP5ao1l Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEhrpukzGPukRmQqkK24/THMrX1ywFAl3yKGQACgkQ24/THMrX 1yyGhwf6Ao9XCbDr3/5+tsoBrYZRGAUiFToowB3TYnozElhzWd6C324buzzhKOAI qQOTLtxe75OamWTSlJgdzPscrPL2e2vmu5zvmJm0qdWaW3+5wOT8SqLt0eXhpLx/ PF9Yyw/cUaXWSlYNZVcYtVC1BaY0Qrnzcb/Pwb90N8QtbUVIexDMZqyJQf9TCxx0 7QppyGr1tA+jT2vtJEEjVpRG978vd4Ma2aNMod3E34pjzGJJ+2p+igdZ9NrIKMwj +BFIKqLXjsmby0WJskDGFQcVqH8Yw116BshrAiSxNcrrviqonGrif41KcqWG54eQ m8UwtNUUAleiStYns1hb0D1OoQjXTA== =+pPz -----END PGP SIGNATURE----- --CMEQapY8OuP5ao1l--