Received: by 10.192.165.148 with SMTP id m20csp2492130imm; Sun, 22 Apr 2018 08:08:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx48O/GB3zR6VpwI0UePdXHJbQa97dR4F6HU7Ge6oJ5LHhnwfP8CUK1N/ozrJiEJkpjrsthAi X-Received: by 10.98.103.86 with SMTP id b83mr16911924pfc.76.1524409706414; Sun, 22 Apr 2018 08:08:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524409706; cv=none; d=google.com; s=arc-20160816; b=dtVkV1p8LhqqdAlXcTg/a5+rUocVJfJvISa8e9tiaFGTlIyHguhYeGJw+Ebq8MZoXY oPMWgI+Dopw5Z1Yj/Fy9PRnqdY1a7Gzs9Zf1jw+xDJAVl0YrYih1Vb126h+kT0e67r+L buvYBTBdB03kGKPwfSzj1PDKg8OtnZ63PvBBAwLj8p66KHOKQKBSlToxKHL8mPj0LEuc aY02EseHwPALmK4U4lZwKls5IARoMdExH6O7yF833DgFGGnTw97qaUskV+6FtatnR3Dj RprRTPI/mUx2dVgLfQe1M+8cZaiop3SMP9mC3p3XswdoYfjH0/0+G1UxG2cXwo6Ye3+R o5ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=1ocXqAOC6GYXRP0dOul5+a+5P22Aw15Oa/GWm3ithxY=; b=0TEuKLs+zjMCaF9W683tni98NV4j5jw9Fu+0mQG0eyhPcq+dkM7CzjPJAPk4jNwgkx nQxnRFJRU/mU4dChTIW1fXNrIYug7bDvfwcSsXGU5CNjkfYdVTX7FaRjqPaQnigCRYB0 6y+nMy7B/YjIqTKpXNkO9yWJhfOlYTDA+c20obZh/VbvMaRkZsPwAcyeUmFLVZQq+WX4 vmkoG1Kvm4UJG8La8jPIMlJB+KIkFBQci7RVEl/yV7YhFlguDGqBpZO1paTVmp1LqZZU 6nG9lGDa20MDMKh+h7QvciH+/1C5mQfH61s2X7e0zHmkZjokhx9MHD+T44fpLaiXBjnE +jeQ== ARC-Authentication-Results: i=1; mx.google.com; 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 h2-v6si9490332plr.320.2018.04.22.08.08.11; Sun, 22 Apr 2018 08:08:26 -0700 (PDT) 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; 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 S1756538AbeDVOLh (ORCPT + 99 others); Sun, 22 Apr 2018 10:11:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:54358 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756496AbeDVOL1 (ORCPT ); Sun, 22 Apr 2018 10:11:27 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 30D20CB8; Sun, 22 Apr 2018 14:11:26 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Andryuk , Eduardo Otubo , Boris Ostrovsky , Juergen Gross Subject: [PATCH 4.9 16/95] xen-netfront: Fix hang on device removal Date: Sun, 22 Apr 2018 15:52:45 +0200 Message-Id: <20180422135211.106716057@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135210.432103639@linuxfoundation.org> References: <20180422135210.432103639@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jason Andryuk commit c2d2e6738a209f0f9dffa2dc8e7292fc45360d61 upstream. A toolstack may delete the vif frontend and backend xenstore entries while xen-netfront is in the removal code path. In that case, the checks for xenbus_read_driver_state would return XenbusStateUnknown, and xennet_remove would hang indefinitely. This hang prevents system shutdown. xennet_remove must be able to handle XenbusStateUnknown, and netback_changed must also wake up the wake_queue for that state as well. Fixes: 5b5971df3bc2 ("xen-netfront: remove warning when unloading module") Signed-off-by: Jason Andryuk Cc: Eduardo Otubo Reviewed-by: Boris Ostrovsky Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- drivers/net/xen-netfront.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -2038,7 +2038,10 @@ static void netback_changed(struct xenbu case XenbusStateInitialised: case XenbusStateReconfiguring: case XenbusStateReconfigured: + break; + case XenbusStateUnknown: + wake_up_all(&module_unload_q); break; case XenbusStateInitWait: @@ -2169,7 +2172,9 @@ static int xennet_remove(struct xenbus_d xenbus_switch_state(dev, XenbusStateClosing); wait_event(module_unload_q, xenbus_read_driver_state(dev->otherend) == - XenbusStateClosing); + XenbusStateClosing || + xenbus_read_driver_state(dev->otherend) == + XenbusStateUnknown); xenbus_switch_state(dev, XenbusStateClosed); wait_event(module_unload_q,