Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9098692pxu; Mon, 28 Dec 2020 06:36:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJze0IXmel5uddd2eTYuelUa/Qlu10SUJR1gUcH0YK/m7/5ZQpNjtYH65g2F6LPvPnvRlnru X-Received: by 2002:a17:906:3b56:: with SMTP id h22mr40875776ejf.491.1609166183833; Mon, 28 Dec 2020 06:36:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166183; cv=none; d=google.com; s=arc-20160816; b=FvlDoXvp4COQ1pRaJd1FO/chXMrVtf3jb/sJAVS43pvAMrZ6vIoHCuxRpL4tBMOadT okPX/s/fEEvHAF6jPu4aZNNqeaIrxSve4WRiWed+voe2+GFHuEky8nmqR5n9Q6P/ZF3n +qig6q8fhGAm7+6vKvLw6/yewU0kKGotF77NtIH0CtzaN1Yijmlvr46rtCYsxw/gWrZb dImKcevau9jjdggWaC7g++tnOZD3lrGwyY4JCC42FaJJZQ2j+i2TshARffti4PKEmdml bDH8m3o2imgG5Lv7VZ9o0D0dUT8/f+tvjLaj8KxZxfd/rurNZ4w+ozDtfcjQGQH2AVHv T/qA== 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=FQMBx2FWsZymyBfeJuKuMm6tbPBE2CMwh/pWAddsRUg=; b=kH0k2Flc1ZOzQIjNcmlpb62q8ivNrDhDlNv+s/80fMp0qaHNNhzGxRE2WahjXULFCR aQuP+4oxzNrvdqpK2VnHzkrV47G8ex/q6qUuynqoOI+ZCz2bVqkbgucfdcAEP0StedHC xCVqZAs2tBTOrNVgcYlZiHiBkeYx0VPwHp7ESIapTJ/kPZ6GWxG+romi76XEyBqtKh3M xZt5Nc7BsJ2FHSa6CmAj9jRMa3l1GbGWx1GRr3fhomnQcIaysWTfW9PSDzfk/HnaDTIK e7o2yweuHibsVTc5ZaRMtMiVli2H4j4CMTTnp4vtOVtgTrLIx2kN769NCirO4Kuid2p2 Qkbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vYq2Bsw5; 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 q11si20249698edn.225.2020.12.28.06.36.01; Mon, 28 Dec 2020 06:36:23 -0800 (PST) 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=vYq2Bsw5; 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 S2504160AbgL1Oc5 (ORCPT + 99 others); Mon, 28 Dec 2020 09:32:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:40496 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504697AbgL1Oc3 (ORCPT ); Mon, 28 Dec 2020 09:32:29 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8EF0D206D4; Mon, 28 Dec 2020 14:31:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165908; bh=uDALmj9vhN9aqQb9DrI8tAJ8kZXOUdgexUxxNHGND1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vYq2Bsw5fLSq/U9hkg+UJhZEKP+YLhPzZYnVsrY3bao2JfqAMudF0a6/AP91Ispk/ uFugJpz0+pNooP9KoiuEs/jasHzmMvpiVOjJe53S6N/sKWClfSt7jc6wr6PQCGkdAx 3W5E83+355WayfSR+WFR0D+1wT9pFKT7WBKbafPE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, SeongJae Park , Michael Kurth , Pawel Wieczorkiewicz , Juergen Gross Subject: [PATCH 5.10 697/717] xen/xenbus: Add will_handle callback support in xenbus_watch_path() Date: Mon, 28 Dec 2020 13:51:35 +0100 Message-Id: <20201228125054.381236372@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: SeongJae Park commit 2e85d32b1c865bec703ce0c962221a5e955c52c2 upstream. Some code does not directly make 'xenbus_watch' object and call 'register_xenbus_watch()' but use 'xenbus_watch_path()' instead. This commit adds support of 'will_handle' callback in the 'xenbus_watch_path()' and it's wrapper, 'xenbus_watch_pathfmt()'. This is part of XSA-349 Cc: stable@vger.kernel.org Signed-off-by: SeongJae Park Reported-by: Michael Kurth Reported-by: Pawel Wieczorkiewicz Reviewed-by: Juergen Gross Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- drivers/block/xen-blkback/xenbus.c | 3 ++- drivers/net/xen-netback/xenbus.c | 2 +- drivers/xen/xen-pciback/xenbus.c | 2 +- drivers/xen/xenbus/xenbus_client.c | 9 +++++++-- drivers/xen/xenbus/xenbus_probe.c | 2 +- include/xen/xenbus.h | 6 +++++- 6 files changed, 17 insertions(+), 7 deletions(-) --- a/drivers/block/xen-blkback/xenbus.c +++ b/drivers/block/xen-blkback/xenbus.c @@ -676,7 +676,8 @@ static int xen_blkbk_probe(struct xenbus /* setup back pointer */ be->blkif->be = be; - err = xenbus_watch_pathfmt(dev, &be->backend_watch, backend_changed, + err = xenbus_watch_pathfmt(dev, &be->backend_watch, NULL, + backend_changed, "%s/%s", dev->nodename, "physical-device"); if (err) goto fail; --- a/drivers/net/xen-netback/xenbus.c +++ b/drivers/net/xen-netback/xenbus.c @@ -824,7 +824,7 @@ static void connect(struct backend_info xenvif_carrier_on(be->vif); unregister_hotplug_status_watch(be); - err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch, + err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch, NULL, hotplug_status_changed, "%s/%s", dev->nodename, "hotplug-status"); if (!err) --- a/drivers/xen/xen-pciback/xenbus.c +++ b/drivers/xen/xen-pciback/xenbus.c @@ -689,7 +689,7 @@ static int xen_pcibk_xenbus_probe(struct /* watch the backend node for backend configuration information */ err = xenbus_watch_path(dev, dev->nodename, &pdev->be_watch, - xen_pcibk_be_watch); + NULL, xen_pcibk_be_watch); if (err) goto out; --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -127,19 +127,22 @@ EXPORT_SYMBOL_GPL(xenbus_strstate); */ int xenbus_watch_path(struct xenbus_device *dev, const char *path, struct xenbus_watch *watch, + bool (*will_handle)(struct xenbus_watch *, + const char *, const char *), void (*callback)(struct xenbus_watch *, const char *, const char *)) { int err; watch->node = path; - watch->will_handle = NULL; + watch->will_handle = will_handle; watch->callback = callback; err = register_xenbus_watch(watch); if (err) { watch->node = NULL; + watch->will_handle = NULL; watch->callback = NULL; xenbus_dev_fatal(dev, err, "adding watch on %s", path); } @@ -166,6 +169,8 @@ EXPORT_SYMBOL_GPL(xenbus_watch_path); */ int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch, + bool (*will_handle)(struct xenbus_watch *, + const char *, const char *), void (*callback)(struct xenbus_watch *, const char *, const char *), const char *pathfmt, ...) @@ -182,7 +187,7 @@ int xenbus_watch_pathfmt(struct xenbus_d xenbus_dev_fatal(dev, -ENOMEM, "allocating path for watch"); return -ENOMEM; } - err = xenbus_watch_path(dev, path, watch, callback); + err = xenbus_watch_path(dev, path, watch, will_handle, callback); if (err) kfree(path); --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -136,7 +136,7 @@ static int watch_otherend(struct xenbus_ container_of(dev->dev.bus, struct xen_bus_type, bus); return xenbus_watch_pathfmt(dev, &dev->otherend_watch, - bus->otherend_changed, + NULL, bus->otherend_changed, "%s/%s", dev->otherend, "state"); } --- a/include/xen/xenbus.h +++ b/include/xen/xenbus.h @@ -204,10 +204,14 @@ void xenbus_probe(struct work_struct *); int xenbus_watch_path(struct xenbus_device *dev, const char *path, struct xenbus_watch *watch, + bool (*will_handle)(struct xenbus_watch *, + const char *, const char *), void (*callback)(struct xenbus_watch *, const char *, const char *)); -__printf(4, 5) +__printf(5, 6) int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch, + bool (*will_handle)(struct xenbus_watch *, + const char *, const char *), void (*callback)(struct xenbus_watch *, const char *, const char *), const char *pathfmt, ...);