Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3407850pxy; Mon, 26 Apr 2021 00:38:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1O4Gcn7rYOAtI7r6CPRbm3Lr7MdM7ZYo2s2sJH1SBxBy57RXob+ZX8Z3mtumsZgCR7OrW X-Received: by 2002:a63:ee0f:: with SMTP id e15mr15779541pgi.310.1619422704891; Mon, 26 Apr 2021 00:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619422704; cv=none; d=google.com; s=arc-20160816; b=cQQO2q1LERM7ZqsRIh+evRrqNL5Dh0luRULgNR7dXi66U6tlElI3x4fCOgWpDFbQJM /3W4MZKDKCOJdpj8UE2GPb8QKO8YitkzWX8cIMDbGU6UUNnEBxXcYsDBSIVsFJ9P52dj scAmx5/nlphyWjHx/PPHQ12hP6lKsk1bk81mct3KYFhFtQk7RkIUINima1niEA5UJXgb +meQlUie8rkxIvlYGBOL6xpGaX+9CSEXykOWKKslQjVr8COwbtkrLvSln5cFR0R64yFU vvn7MFvRU/WOvVj3r3LHPYS9mD6mmylL9AyY1/OZPfVn/cVWz+E1bCpR/8IdPwTsOrUA 84jQ== 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=RDIFG18TGvtJNK8sUJREAYIJpg56ELfDo8YFFXfZhA0=; b=XOgqfMweejdyBJ1SlWV66BKOYPqAsU2dBgcQEyjo/h4jBS9WoK7QNYWFssKyQIwH4M PNyI9dcxO1jKtUX8rHScJCpe5of8EIFm54ACFiNWlFVaxcdhBxZCjyPdbT334dfYhLR4 TjOABsiYwV94AvlbLi5QRwWax4SNt6vy1fmDM1A7TnsrL3cTKPCUwqPTyIgnAb9N8Z1f qgidRcJLupv/1OR4lofCI4IJbdniZfvmcDQqnD+wCmMigYwSlPfJNKTyeifn3mopQjdW Q4rw1qqyAtW4xQUPkr8xL4v/N8oXimAZ2i15cNpXAmHWqTcvswGsY0d6LqLPLUsqL00r oOfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GQUeEWlp; 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 y8si17189228plk.154.2021.04.26.00.38.12; Mon, 26 Apr 2021 00:38:24 -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=GQUeEWlp; 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 S232754AbhDZHhp (ORCPT + 99 others); Mon, 26 Apr 2021 03:37:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:46576 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232172AbhDZHd7 (ORCPT ); Mon, 26 Apr 2021 03:33:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5B5FA611BD; Mon, 26 Apr 2021 07:33:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1619422397; bh=84fEXRoir9ZD96qpuD0HzoQzv/MQfRsgEFL6wgpLaVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GQUeEWlpb0PboCNaInyhSuP8AW+4k0+/zPg8Lx6LacrJg3obrkZe4tK31WfwirQ/0 jWGbE/fi6yHGNFtclKChJO/bY09RDg3kbxkYV88X7HiXktdtpNWbBJN7EYm2RgWmhj TDpSNkj6gNzALs1Vzzij1Eg726b+i1jzbHXOAcKs= 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.9 33/37] xen-netback: Check for hotplug-status existence before watching Date: Mon, 26 Apr 2021 09:29:34 +0200 Message-Id: <20210426072818.365616663@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210426072817.245304364@linuxfoundation.org> References: <20210426072817.245304364@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 78788402edd8..e6646c8a7bdb 100644 --- a/drivers/net/xen-netback/xenbus.c +++ b/drivers/net/xen-netback/xenbus.c @@ -1040,11 +1040,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