From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88937C49EA7 for ; Thu, 24 Jun 2021 08:12:41 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2DC58613E7 for ; Thu, 24 Jun 2021 08:12:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2DC58613E7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.146482.269524 (Exim 4.92) (envelope-from ) id 1lwKTL-0001QQ-F7; Thu, 24 Jun 2021 08:12:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 146482.269524; Thu, 24 Jun 2021 08:12:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lwKTL-0001QJ-C3; Thu, 24 Jun 2021 08:12:27 +0000 Received: by outflank-mailman (input) for mailman id 146482; Thu, 24 Jun 2021 08:12:25 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lwKTJ-0001Q1-QP for xen-devel@lists.xenproject.org; Thu, 24 Jun 2021 08:12:25 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lwKTI-0003h0-Da; Thu, 24 Jun 2021 08:12:24 +0000 Received: from [54.239.6.182] (helo=a483e7b01a66.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lwKTI-0003U5-4I; Thu, 24 Jun 2021 08:12:24 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject; bh=/gquh0QLxtElZLGe9Zcszyit3MGZK73YXaXO2qqDKdQ=; b=BtDpAHRbmszwrMgEEt3aBGepBf 5YDbunzQWJnsCwADak7gplQPY5NADMHxP5d8cypECRCSOmdw9sEFA2TUfvt7+B+o8ZUbrOiMOsqzt vR0A6PpKnbDuZbwrHwVJEqaLJCClGACm8EaLkwsb6Bf0wehwrSeWZHSJCrqcDTtzRAUM=; Subject: Re: [PATCH] tools/xenstored: Don't crash xenstored when Live-Update is cancelled To: Juergen Gross , xen-devel@lists.xenproject.org Cc: raphning@amazon.co.uk, doebel@amazon.de, Julien GralL , Ian Jackson , Wei Liu References: <20210617173857.6450-1-julien@xen.org> <136d6a10-c93d-accd-fc34-62fbaa4742b0@suse.com> From: Julien Grall Message-ID: <325bf694-a30f-558c-ab84-d8a7a1865cc2@xen.org> Date: Thu, 24 Jun 2021 10:12:21 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <136d6a10-c93d-accd-fc34-62fbaa4742b0@suse.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Hi Juergen, On 22/06/2021 11:23, Juergen Gross wrote: > On 17.06.21 19:38, Julien Grall wrote: >> From: Julien GralL >> >> 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 >> >> ---- >> >> 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; > > This will set conn to the same value it already has. Ah yes. I will drop this line. Also, I took the opportunity to replace } else assert(...) with just assert(...) This should improve a bit the readability. Let me know if you want me to resend the patch for that. > > > Other than that: > > Reviewed-by: Juergen Gross Thank you! Cheers, -- Julien Grall