From: Luca Fancellu <luca.fancellu@arm.com>
To: Julien Grall <julien@xen.org>
Cc: xen-devel@lists.xenproject.org, raphning@amazon.co.uk,
doebel@amazon.de, Julien GralL <jgrall@amazon.com>,
Ian Jackson <iwj@xenproject.org>, Wei Liu <wl@xen.org>,
Juergen Gross <jgross@suse.com>
Subject: Re: [PATCH] tools/xenstored: Don't crash xenstored when Live-Update is cancelled
Date: Mon, 21 Jun 2021 10:36:47 +0100 [thread overview]
Message-ID: <3AC8670C-7FA8-4968-951A-E67E95B0AF97@arm.com> (raw)
In-Reply-To: <20210617173857.6450-1-julien@xen.org>
> On 17 Jun 2021, at 18:38, Julien Grall <julien@xen.org> wrote:
>
> From: Julien GralL <jgrall@amazon.com>
>
> 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@amazon.com>
Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
>
> ----
>
> This is currently based on top of:
>
> https://lore.kernel.org/xen-devel/20210616144324.31652-1-julien@xen.org
>
> 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
>
>
next prev parent reply other threads:[~2021-06-21 9:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-17 17:38 [PATCH] tools/xenstored: Don't crash xenstored when Live-Update is cancelled Julien Grall
2021-06-21 9:36 ` Luca Fancellu [this message]
2021-06-22 8:46 ` Juergen Gross
2021-06-22 8:53 ` Julien Grall
2021-06-22 9:13 ` Juergen Gross
2021-06-22 9:23 ` Juergen Gross
2021-06-24 8:12 ` Julien Grall
2021-06-24 8:17 ` Juergen Gross
2021-06-24 8:18 ` Julien Grall
2021-06-24 11:17 ` Julien Grall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3AC8670C-7FA8-4968-951A-E67E95B0AF97@arm.com \
--to=luca.fancellu@arm.com \
--cc=doebel@amazon.de \
--cc=iwj@xenproject.org \
--cc=jgrall@amazon.com \
--cc=jgross@suse.com \
--cc=julien@xen.org \
--cc=raphning@amazon.co.uk \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).