[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] tools/xenstored: Don't crash xenstored when Live-Update is cancelled


  • To: Julien Grall <julien@xxxxxxx>
  • From: Luca Fancellu <luca.fancellu@xxxxxxx>
  • Date: Mon, 21 Jun 2021 10:36:47 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ka8N4Ch0f35EKm0tUvbUB0qb6lt5G0qJTeudjEJziC4=; b=KTfdCUXvZUy6bstRVJoCcRl2M1Fn5150P3tgf6COm3TL+wZjo/qb3DzgDpn0iE4yVHT+cCPD6ICawsHDfllgies1bCshotBfvFWM0l39NnnK52QFf9If2ZNskAnIb1S+1/itO2W5l4Sz/Z66PxMEyY3RoDbbB1rnhYE29FYUMRJS0dPrLZeQaghuBmYUt8EijVTSboL+zb+g9LyBKPSVcl+71aW3g3N/bACKpOIqDsEM6WGzhnFGmaOR5HpqwhBvmVHUHEd7s762Q+sALendDED572kdoK1EhQSIbgEYXiBtbEBJUBQ/MAFb+dAcMvrINcBFLL9+xeydn4zhY1oJlg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IPRZmp2/ePj/Wa+kQvGpwq3YdPCtLSk31aTz3ONJ2kQ2U96f6VISxMf9RlFEtzSMlyKMwrg7FKDwhW7/ZMRq6Mfpobdw3ODu205qgAlt4SS1S9Oho5T8XB0PnpMEanCBWf0VubauYMKF/V6ckgTmBzU82inMvV02qWup+bXAUl/QlIwCUGFqzJdx1jNLW72jKcStxTouyK8XM56uhCdE8PBhVkX00FnCdZgo+EInXaAy95CyNQs30jZgvJ1lNTL4zkFP9BVQsk47tgbkV5GgM9rm/08/TOtbCYR0YAOXO0Nwz5rYmsbNcwSJpXX+U6vMuPsEnGf8t1fYkr6OLT5pbg==
  • Authentication-results-original: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, raphning@xxxxxxxxxxxx, doebel@xxxxxxxxx, Julien GralL <jgrall@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Mon, 21 Jun 2021 09:37:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;


> On 17 Jun 2021, at 18:38, Julien Grall <julien@xxxxxxx> wrote:
> 
> From: Julien GralL <jgrall@xxxxxxxxxx>
> 
> As Live-Update is asynchronous, it is possible to receive a request to
> cancel it (either on the same connection or from a different one).
> 
> Currently, this will crash xenstored because do_lu_start() assumes
> lu_status will be valid. This is not the case when Live-Update has been
> cancelled. This will result to dereference a NULL pointer and
> crash Xenstored.
> 
> Rework do_lu_start() to check if lu_status is NULL and return an
> error in this case.
> 
> Fixes: af216a99fb ("tools/xenstore: add the basic framework for doing the 
> live update")
> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>

Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>

> 
> ----
> 
> This is currently based on top of:
> 
> https://lore.kernel.org/xen-devel/20210616144324.31652-1-julien@xxxxxxx
> 
> This can be re-ordered if necessary.
> ---
> tools/xenstore/xenstored_control.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/xenstore/xenstored_control.c 
> b/tools/xenstore/xenstored_control.c
> index a045f102a420..37a3d39f20b5 100644
> --- a/tools/xenstore/xenstored_control.c
> +++ b/tools/xenstore/xenstored_control.c
> @@ -696,7 +696,18 @@ static bool do_lu_start(struct delayed_request *req)
>       time_t now = time(NULL);
>       const char *ret;
>       struct buffered_data *saved_in;
> -     struct connection *conn = lu_status->conn;
> +     struct connection *conn = req->data;
> +
> +     /*
> +      * Cancellation may have been requested asynchronously. In this
> +      * case, lu_status will be NULL.
> +      */
> +     if (!lu_status) {
> +             ret = "Cancellation was requested";
> +             conn = req->data;
> +             goto out;
> +     } else
> +             assert(lu_status->conn == conn);
> 
>       if (!lu_check_lu_allowed()) {
>               if (now < lu_status->started_at + lu_status->timeout)
> @@ -747,7 +758,7 @@ static const char *lu_start(const void *ctx, struct 
> connection *conn,
>       lu_status->timeout = to;
>       lu_status->started_at = time(NULL);
> 
> -     errno = delay_request(conn, conn->in, do_lu_start, NULL, false);
> +     errno = delay_request(conn, conn->in, do_lu_start, conn, false);
> 
>       return NULL;
> }
> -- 
> 2.17.1
> 
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.