Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3417357pxy; Mon, 26 Apr 2021 00:56:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnQA764BcxYzDa24MCoVEMhw6d1naGCNdwndsx4nGqmT7YZ2nF7Z74IOmeEGkQRUOEi11q X-Received: by 2002:aa7:8b0f:0:b029:20d:1b60:e823 with SMTP id f15-20020aa78b0f0000b029020d1b60e823mr16331845pfd.16.1619423808083; Mon, 26 Apr 2021 00:56:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619423808; cv=none; d=google.com; s=arc-20160816; b=rKNgn111oX45NHI32gY5pAZ6Ae/632PGE/0fYqbtl9YQrfc08H+izgopskrME1qHsL cHnTz0JiRCpxw4PIgFTtFR285FJjju31TY+FBB3mBjr08qTRnf09iSy0cH8maS/ty7Cs IoZb1xVYMPluRilGvgjc0pO2Hd+ZtVwVOA7m3yKC0fJTiDqOD30C6/9bOKX4W1qcl6A/ /nOxTsanJfHADI+lx5LdcViOCO+DARUehoenxHfC8fk0/F8UcFUlvZQe8JXrGJTd8L6t KZZU/S2vJ7JiHe8y3JM3wNqz68kMrwRS0hFBDbDZAnu9GLF/udEquE8m/DKuhs4y64yj c3kQ== 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=qggKWHxc2EsEXrvWUGdnzrItGXsXVvpicRgCI2XC/R8=; b=RiJhsDJqvIeuisAJHtnEd1wA02zuCGZAMQzYDhVrUVMQdkPsiOmzRS4ZWYbfqSh1ks gRye5/SErUWsaOWy1zlG4LdKyVaUuW2Kdy+Bc8t7TvASRy2nVXUcG5wNHWVxu1HlA8l4 23DNuLdwiMvcSas9nJcOUoebWTm2Ong9ZmvLN0mPADgx3+VBvZpRC7svGU3PQulkHMQa HSP3ip62+GoBgDEYxYn3NFQSS7xeX+CfgQfUmzEbv4d/wBvlWgxeBirk6cJbDYqjHd3O d3rX2AcXkePe10xWq419++0+3LRHnK6ZleJE2A/v28LPCYS1TUft5Yv9I8BDvqhddh9t A8kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uPVzbpEe; 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 k3si17473456pgt.359.2021.04.26.00.56.35; Mon, 26 Apr 2021 00:56:48 -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=uPVzbpEe; 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 S233619AbhDZHx3 (ORCPT + 99 others); Mon, 26 Apr 2021 03:53:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:33434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232862AbhDZHn5 (ORCPT ); Mon, 26 Apr 2021 03:43:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E179F613C9; Mon, 26 Apr 2021 07:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1619422818; bh=3m3lFg+7CrTJgU9IHDfJ4YqA/Dn5bG9FWVMD5FrUKY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uPVzbpEeCV0fmxrXyhE8d78FjWOYP4UmHteLcucE1JnVGV/fhoa3raAVnLHiRJ4V+ 7wYco1OzXOAm7yNbBTkhXTESouXfupdAdO0d+7O2yLVtQpM95oy/g/r9ERhafSD5ae /o8+F2AlgRxTQ+YNABp3l3tnM1FKjEIqWq4Kvr00= 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 5.10 30/36] xen-netback: Check for hotplug-status existence before watching Date: Mon, 26 Apr 2021 09:30:12 +0200 Message-Id: <20210426072819.807848767@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210426072818.777662399@linuxfoundation.org> References: <20210426072818.777662399@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 6f10e0998f1c..94d19158efc1 100644 --- a/drivers/net/xen-netback/xenbus.c +++ b/drivers/net/xen-netback/xenbus.c @@ -824,11 +824,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