From nobody Fri May 3 10:44:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1623951583; cv=none; d=zohomail.com; s=zohoarc; b=d+aR/hwSzLxt4i2QZR6SvGPC4EN+v8oIN+EZOEBpwiMCcmS6n2Pi/1OIkv2MBjqOrTeaHRq4XFobIceHKn79rTtFzWktRVR58Plzsz86iR/6h38ULP69lUQl5kz3645YZkVLAqCOvBQ4wbTAjrH68A7vAr0unBz3YXfot45Rp5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623951583; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=YCJ6YwBhcj+J/NT2ZL9DliHisUCCsiW9BvW2U/IOO7k=; b=UY1iFSjl1+rF1FLShOv0z9ZwavtKgblzKDI8O9pTalFVXsRtU4qn14ASaUnhqpO8SYbMp7w06+pkJWvk55LYlvGIWIYwj0ZvgdMGlyalYYlhPd68bd0ml66mH+DEoPyaF8BNQ4KP7K8pZPOh+KAt9NbdNCv/S1z9MoDx1jr/4Yg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1623951583093911.4590081674717; Thu, 17 Jun 2021 10:39:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.144104.265298 (Exim 4.92) (envelope-from ) id 1ltvz0-0006C7-KU; Thu, 17 Jun 2021 17:39:14 +0000 Received: by outflank-mailman (output) from mailman id 144104.265298; Thu, 17 Jun 2021 17:39:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ltvz0-0006C0-HW; Thu, 17 Jun 2021 17:39:14 +0000 Received: by outflank-mailman (input) for mailman id 144104; Thu, 17 Jun 2021 17:39:12 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ltvyy-0006Bt-NB for xen-devel@lists.xenproject.org; Thu, 17 Jun 2021 17:39:12 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ltvyw-0006QJ-Tj; Thu, 17 Jun 2021 17:39:10 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ltvyw-0005rm-J9; Thu, 17 Jun 2021 17:39:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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=Message-Id:Date:Subject:Cc:To:From; bh=YCJ6YwBhcj+J/NT2ZL9DliHisUCCsiW9BvW2U/IOO7k=; b=QTV/RS55dT4GgwXF8tblze5OSE U2AqSOWtgWVKQgfEGN6Re+9h6/+uSY5EXdR5Wf1Fxht3k3u2EDhq19hsE5HMNKgFsOTTEajJBE6nR WVqQaqoQD3/nnlsnFv1d8Z/jcHBRtcKvc4fH05jgy4X1bSKPgQUPG8lL362vBm4WOZS8=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: raphning@amazon.co.uk, doebel@amazon.de, Julien GralL , Ian Jackson , Wei Liu , Juergen Gross , Julien Grall Subject: [PATCH] tools/xenstored: Don't crash xenstored when Live-Update is cancelled Date: Thu, 17 Jun 2021 18:38:57 +0100 Message-Id: <20210617173857.6450-1-julien@xen.org> X-Mailer: git-send-email 2.17.1 X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 l= ive update") Signed-off-by: Julien Grall Reviewed-by: Juergen Gross Reviewed-by: Luca Fancellu ---- 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 =3D time(NULL); const char *ret; struct buffered_data *saved_in; - struct connection *conn =3D lu_status->conn; + struct connection *conn =3D req->data; + + /* + * Cancellation may have been requested asynchronously. In this + * case, lu_status will be NULL. + */ + if (!lu_status) { + ret =3D "Cancellation was requested"; + conn =3D req->data; + goto out; + } else + assert(lu_status->conn =3D=3D conn); =20 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 con= nection *conn, lu_status->timeout =3D to; lu_status->started_at =3D time(NULL); =20 - errno =3D delay_request(conn, conn->in, do_lu_start, NULL, false); + errno =3D delay_request(conn, conn->in, do_lu_start, conn, false); =20 return NULL; } --=20 2.17.1