Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13388447ybl; Sun, 29 Dec 2019 10:41:42 -0800 (PST) X-Google-Smtp-Source: APXvYqw21en9BzpXbRnDk/nGqiQzBEYGLJxX9nKVR/WePPewmeqyXojdH1ruO+Lp8JlmpTVuGzhF X-Received: by 2002:a9d:51ca:: with SMTP id d10mr67478521oth.76.1577644902062; Sun, 29 Dec 2019 10:41:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577644902; cv=none; d=google.com; s=arc-20160816; b=fSM9irliDJEsJsH5C2VaYp/TZBt4muHzC1yLyH5AXj1eOuhDZVBqQt0zLa6WRtxtyi yHa17UcYfdAyHqBGNgoAT3T6V4Q0E4EsYlZM8IBF9axwXzQ2QDx5wOvv6zQwNP+ay/nC 3di721gvCxlwWpMPvGJoki5txbEW5Yi4VLQ6LYmEYnlRtH+Yx92zhVyG1i78PE+j9Faf etFaougsPY/FYiS8f5/n3/EUhpCp4LiZFKL61jMF2c/+o78tzBLqbOqUm8Cpaglh9ciH vn1vD6Mjm/BvDSEE6OT8ylTyAlOaqzYw0+KrWk/F7bzLHM+S5kihdHctM+gYCiyF1UPk otNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XCaTNP6slQ53TPpyO+AiGujomQ3xN50O7EDDaXyNhrk=; b=AzFEQwIZP0xtsTqLx2t1leJCpap1PvYPMqoSSbRTE8qDjRl0PSNn0pDym7enzQ4pm9 VamllJEDwk4wJkWh93Rwl+QSITKdVxM3qYONj7L1WNXhWAwtk6AY0VNgFcuP5pNOcyfR F1vR5R9TkMs0aQJtNMS312Io2sf8NM5gpZK2k4mh19kdiKhsXNa2RHQYIRuNxVsheza9 xAtfPDM9iU276ALe5IrQaQ2tHuWj7u96X04KtPRnjRwJ6FjLooGHiFy8/F0NrIVk+3O3 XfkCTYXc8Vrbe/eYzFIbdhRaLyYVmeF9EBPRxH8BAXqUhBSRzm/wq+fNTvpeovEhyioe litg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mvuz4BJn; 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 a15si18332233otq.83.2019.12.29.10.41.30; Sun, 29 Dec 2019 10:41:42 -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=@kernel.org header.s=default header.b=mvuz4BJn; 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 S1727960AbfL2R0u (ORCPT + 99 others); Sun, 29 Dec 2019 12:26:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:48306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728287AbfL2R0r (ORCPT ); Sun, 29 Dec 2019 12:26:47 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4FA34207FD; Sun, 29 Dec 2019 17:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640406; bh=889MMMOWTKQC9eo1k1KV2liBOhBAgfC465dHDg30NuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mvuz4BJnHSSjAgcAQBDG6Rsped6bZKVYtogWYy8auf8sh476Fyha2c2y4LhKtUGok IfvCGgO4h+bqNrIpVG++tXO5T6jx+G9KBla5TJod14bmRUWm+lnYqJvVnGSWLVHb6B FkzgqrKqjqiE1xjbfPR/aHGgKb5WbLw38bSJQV6k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Suwan Kim , Shuah Khan Subject: [PATCH 4.14 145/161] usbip: Fix error path of vhci_recv_ret_submit() Date: Sun, 29 Dec 2019 18:19:53 +0100 Message-Id: <20191229162444.171925711@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162355.500086350@linuxfoundation.org> References: <20191229162355.500086350@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suwan Kim commit aabb5b833872524eaf28f52187e5987984982264 upstream. 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(). 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 “vhci_priv". So, in the case of transaction error in vhci_recv_ret_submit(), unlink URB from the endpoint, insert proper error code in urb->status and give back URB. Reported-by: Marek Marczykowski-Górecki Tested-by: Marek Marczykowski-Górecki Signed-off-by: Suwan Kim Cc: stable Acked-by: Shuah Khan Link: https://lore.kernel.org/r/20191213023055.19933-3-suwan.kim027@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/usbip/vhci_rx.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) --- a/drivers/usb/usbip/vhci_rx.c +++ b/drivers/usb/usbip/vhci_rx.c @@ -91,16 +91,21 @@ static void vhci_recv_ret_submit(struct usbip_pack_pdu(pdu, urb, USBIP_RET_SUBMIT, 0); /* recv transfer buffer */ - if (usbip_recv_xbuff(ud, urb) < 0) - return; + if (usbip_recv_xbuff(ud, urb) < 0) { + urb->status = -EPROTO; + goto error; + } /* recv iso_packet_descriptor */ - if (usbip_recv_iso(ud, urb) < 0) - return; + if (usbip_recv_iso(ud, urb) < 0) { + urb->status = -EPROTO; + goto error; + } /* restore the padding in iso packets */ usbip_pad_iso(ud, urb); +error: if (usbip_dbg_flag_vhci_rx) usbip_dump_urb(urb);