Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3410216pxy; Mon, 26 Apr 2021 00:43:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBuoZDU5OzRZEr1Y/oY+TNqZZxc7xHJkamdXl5KmThKeOjjUBfOT1tSbsxkbZ8yt0D5+aP X-Received: by 2002:a62:8382:0:b029:272:cfa2:edf5 with SMTP id h124-20020a6283820000b0290272cfa2edf5mr9190828pfe.27.1619423008855; Mon, 26 Apr 2021 00:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619423008; cv=none; d=google.com; s=arc-20160816; b=SP0lGJ//mwotQHnGZWmJ5wyFbRqrN+J1m79KMak12s1/LYhHegP7UH6XtjNSdHu50h Fp+k/I61xSzwgx/K+R7Qag9FZa/C4419WY6Ky07zt6s/NatJ+5i4RXLZz8J4YB25fs/D 6kfd1OaLjIB7FE1wXkFSRvP7JjAiV+gJbIF35n9mYw1SH1CAWCf3TM9LOPDxXBYXJqOv PP9ytaY+a9x5eBrYn6cE4TpSIMY1j9aGXSJEPUp3aQdnqwdkEnTJivIbQejX9L5ThyWX xFeLqPKgKIynkRVkbXNuqXetbAgJBb521sZCacEI05ciT3cK+SF/PwROHmt6TT/rJFYu Nutg== 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=+pQ3Sat1Zi7QlaPuUidUWi7ZN+UslT813BRj4S+gBPc=; b=fFgncQ30wS2XAuiG8vrOC4AHo3Dns3LDjfZ0TpYJSp9He6U9m+Meq4iWSJK6RSBaam 6iwdd6d8Mm5A1+OSNQru+EDFaqz9IIHZ7uKFB9JOycXuh+h9PuMHgZ9ymJjIj2SBQ+SD 1VD2tFxrGbwYJWxB032/tp9IkTYhV4y0S1Yt0a24P3GN/zkref7SzBT2h8nl+sQy344L P8OstuWbl2P9x1hleCYbYzoicAuLM0WRZHxu3Jxav2JrmHzm8thCYGkIZov6Rhl7F64d bM+pfjwjkjVmIdRj2GKj+LlIiSifKZo5MEUGta83fs6bYIDZMbKYJCrlW5gAUJP/YP/z DE+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uhqbfP9t; 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 x6si16192835pfm.286.2021.04.26.00.43.16; Mon, 26 Apr 2021 00:43:28 -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=uhqbfP9t; 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 S233147AbhDZHlk (ORCPT + 99 others); Mon, 26 Apr 2021 03:41:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:46726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232731AbhDZHhW (ORCPT ); Mon, 26 Apr 2021 03:37:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0B9BC613D0; Mon, 26 Apr 2021 07:35:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1619422518; bh=g2eIx8Az/Bb0zYkng6cw8qgVnkYdIcpHR3F4HJvjseM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uhqbfP9tdxTwJF28iZ3PESxPCThFwcjd4FY2SdLcyNynVs3Xk4ILJkmYroWeEunIp UyN8fz6pKzRF0p8RcjFvJOUCL4i/QOQsWfIyFqhujHP+m+Wd4bZZH23RYNIiLxANSo VAXEQtochR2tD/mt3iarj57uD/o9/6zdlfX8Tsjo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Brown , Paul Durrant , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 45/49] xen-netback: Check for hotplug-status existence before watching Date: Mon, 26 Apr 2021 09:29:41 +0200 Message-Id: <20210426072821.262786809@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210426072819.721586742@linuxfoundation.org> References: <20210426072819.721586742@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: Michael Brown [ Upstream commit 2afeec08ab5c86ae21952151f726bfe184f6b23d ] The logic in connect() is currently written with the assumption that xenbus_watch_pathfmt() will return an error for a node that does not exist. This assumption is incorrect: xenstore does allow a watch to be registered for a nonexistent node (and will send notifications should the node be subsequently created). As of commit 1f2565780 ("xen-netback: remove 'hotplug-status' once it has served its purpose"), this leads to a failure when a domU transitions into XenbusStateConnected more than once. On the first domU transition into Connected state, the "hotplug-status" node will be deleted by the hotplug_status_changed() callback in dom0. On the second or subsequent domU transition into Connected state, the hotplug_status_changed() callback will therefore never be invoked, and so the backend will remain stuck in InitWait. This failure prevents scenarios such as reloading the xen-netfront module within a domU, or booting a domU via iPXE. There is unfortunately no way for the domU to work around this dom0 bug. Fix by explicitly checking for existence of the "hotplug-status" node, thereby creating the behaviour that was previously assumed to exist. Signed-off-by: Michael Brown Reviewed-by: Paul Durrant Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/xen-netback/xenbus.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c index 910322b442bd..9092b55e087f 100644 --- a/drivers/net/xen-netback/xenbus.c +++ b/drivers/net/xen-netback/xenbus.c @@ -1043,11 +1043,15 @@ static void connect(struct backend_info *be) xenvif_carrier_on(be->vif); unregister_hotplug_status_watch(be); - err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch, NULL, - hotplug_status_changed, - "%s/%s", dev->nodename, "hotplug-status"); - if (!err) + if (xenbus_exists(XBT_NIL, dev->nodename, "hotplug-status")) { + err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch, + NULL, hotplug_status_changed, + "%s/%s", dev->nodename, + "hotplug-status"); + if (err) + goto err; be->have_hotplug_status_watch = 1; + } netif_tx_wake_all_queues(be->vif->dev); -- 2.30.2