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

[PATCH v20210601 06/38] tools: use xc_is_known_page_type


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Olaf Hering <olaf@xxxxxxxxx>
  • Date: Tue, 1 Jun 2021 18:10:46 +0200
  • Arc-authentication-results: i=1; strato.com; dkim=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1622563888; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=RFOd7y+e4U6vNTZpXSTmtkhWhMZi9HHw/wrHDQUGpSw=; b=KV23dBncIbEZihTRJbO4NExxqIwqU+zmmb2U04PlPeViIOHVkHmAXuPMjMetbsB+sA 50bEcZHMKh+JzeyPG26RPoFoYAzqfLJYCV2uTAyqBwjQ58ohOl4WXvh6gFsYiUrQvM93 KhDlexcoE06Osg5GCFfnKvqr+8NHWh7ufZU0/E5LvIrEWYlozQGUYu5nU5W82e/DZnum tjDNzGlFdkvbrL7hM0G3YaPSWH/UMPReJQ4e+eRP8ozXqOQinhjXeYaVNjJxfpW+Lybn BujRGqhEU6cxPfqql9XXrPlqPrutr/2zgdK6Uq7/g/LnhGMqMuvI8QlhIL/VCxENTSmt a//w==
  • Arc-seal: i=1; a=rsa-sha256; t=1622563888; cv=none; d=strato.com; s=strato-dkim-0002; b=DgU87WsRh140kAE9TWo8r3FrWteINAYMMfUBdn8sMf+WLhlYtnUV+9gTzJ2ZhipOFk +o7WvTY1KoYyCYNg/mvF09j44xxF034sxcTh8r/Coc51YIcmmJVF8i8/CuOarsNGiPvH Ux1To3IUtDs5VAXJ/zrj8S11JEiiJk7Fpe/KNRelscm/lQwXnIwDd2Plpg14qyuW8O6i ewxJT4xHE287ykPD8o09R7p4oJ7IDu+okvS3lTrOXNJuBjhM/XKlPckvaf3cwSJW8a0A sUvK+gQ/5AA3DgjcIJUkVDpus2wG18Uc9U0XqiK44gjdxs+V0ulLGY+EHXOtkbNOQPaf 0QSA==
  • Authentication-results: strato.com; dkim=none
  • Cc: Olaf Hering <olaf@xxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 01 Jun 2021 16:11:35 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Verify pfn type on sending side, also verify incoming batch of pfns.

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
---
 tools/libs/saverestore/restore.c | 3 +--
 tools/libs/saverestore/save.c    | 6 ++++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/libs/saverestore/restore.c b/tools/libs/saverestore/restore.c
index be259a1c6b..cccb0dcb71 100644
--- a/tools/libs/saverestore/restore.c
+++ b/tools/libs/saverestore/restore.c
@@ -406,8 +406,7 @@ static int handle_page_data(struct xc_sr_context *ctx, 
struct xc_sr_record *rec)
         }
 
         type = (pages->pfn[i] & PAGE_DATA_TYPE_MASK) >> 32;
-        if ( ((type >> XEN_DOMCTL_PFINFO_LTAB_SHIFT) >= 5) &&
-             ((type >> XEN_DOMCTL_PFINFO_LTAB_SHIFT) <= 8) )
+        if ( xc_is_known_page_type(type) == false )
         {
             ERROR("Invalid type %#"PRIx32" for pfn %#"PRIpfn" (index %u)",
                   type, pfn, i);
diff --git a/tools/libs/saverestore/save.c b/tools/libs/saverestore/save.c
index 92d96b0533..8d449ee0ae 100644
--- a/tools/libs/saverestore/save.c
+++ b/tools/libs/saverestore/save.c
@@ -147,6 +147,12 @@ static int write_batch(struct xc_sr_context *ctx)
 
     for ( i = 0; i < nr_pfns; ++i )
     {
+        if ( xc_is_known_page_type(types[i]) == false )
+        {
+            ERROR("Wrong type %#"PRIpfn" for pfn %#"PRIpfn, types[i], mfns[i]);
+            goto err;
+        }
+
         switch ( types[i] )
         {
         case XEN_DOMCTL_PFINFO_BROKEN:



 


Rackspace

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