From patchwork Thu Mar 30 16:32:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9654797 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 24EB560349 for ; Thu, 30 Mar 2017 16:40:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16C1E285C6 for ; Thu, 30 Mar 2017 16:40:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A0F3285C5; Thu, 30 Mar 2017 16:40:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AFF722852B for ; Thu, 30 Mar 2017 16:40:23 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctd5a-0001ho-HD; Thu, 30 Mar 2017 16:38:22 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctd5Z-0001hQ-LK for xen-devel@lists.xen.org; Thu, 30 Mar 2017 16:38:21 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 0C/37-19731-C743DD85; Thu, 30 Mar 2017 16:38:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmplkeJIrShJLcpLzFFi42JxWrrBXrfG5G6 EwZetQhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bp3hlMBf8EKl5O+cTUwHiOp4uRk0NCwF/i +4seRhCbTUBfYveLT0wgtoiAusTpjousIDazQI3Exd7dYHFhgUyJR6/72EBsFgFViReXLoDV8 Ap4Srw6sIQFYqacxPnjP5lBbE4BL4n5C/+D2UJANc82LWCEsNUkrvVfYofoFZQ4OfMJC8QuCY mDL14wT2DknYUkNQtJagEj0ypGjeLUorLUIl0jY72kosz0jJLcxMwcXUMDM73c1OLixPTUnMS kYr3k/NxNjMDgYQCCHYx/5gceYpTkYFIS5a1QvxshxJeUn1KZkVicEV9UmpNafIhRhoNDSYLX 1hgoJ1iUmp5akZaZAwxjmLQEB4+SCK8kSJq3uCAxtzgzHSJ1ilFRSpzXGSQhAJLIKM2Da4PFz iVGWSlhXkagQ4R4ClKLcjNLUOVfMYpzMCoJ8742AprCk5lXAjf9FdBiJqDF4ja3QBaXJCKkpB oYo0qv651VluiKmlPis/ThWRN295KGVcFHlNaI+u+J4DvZFGCx+XGLb8ZD56d7n//esWDyhs8 W/r3tDc/Eu6VXupy4wCVWZrdD4h9X1G6O4xa2nvUtn9Yd1dwRn+Wj9edU3/drLjLXl0hbfCqf MUdgX96126JdaSdyvuvLH7yavnBStXuA9HdvJZbijERDLeai4kQAmvGwXpgCAAA= X-Env-Sender: prvs=255f3432a=Andrew.Cooper3@citrix.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1490891897!57754406!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25030 invoked from network); 30 Mar 2017 16:38:20 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-3.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 30 Mar 2017 16:38:20 -0000 X-IronPort-AV: E=Sophos;i="5.36,247,1486425600"; d="scan'208";a="425498504" From: Andrew Cooper To: Xen-devel Date: Thu, 30 Mar 2017 17:32:33 +0100 Message-ID: <1490891554-28597-4-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1490891554-28597-1-git-send-email-andrew.cooper3@citrix.com> References: <1490891554-28597-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Julien Grall , Ian Jackson Subject: [Xen-devel] [PATCH for-4.9 3/4] tools/python: Adjust migration v2 library to warn about zero-content records X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP These records shouldn't be in a stream, but accidentally are. Warn about them, but don't abort the verification. While here, add a missing length check to the X86_PV_P2M_FRAMES record checker. Signed-off-by: Andrew Cooper Reviewed-by: Wei Liu --- CC: Ian Jackson CC: Julien Grall --- tools/python/xen/migration/libxc.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/python/xen/migration/libxc.py b/tools/python/xen/migration/libxc.py index 6fd3f6d..f24448a 100644 --- a/tools/python/xen/migration/libxc.py +++ b/tools/python/xen/migration/libxc.py @@ -312,6 +312,10 @@ class VerifyLibxc(VerifyBase): def verify_record_x86_pv_p2m_frames(self, content): """ x86 PV p2m frames record """ + if len(content) < 8: + raise RecordError("x86_pv_p2m_frames: record length must be at" + " least 8 bytes long") + if len(content) % 8 != 0: raise RecordError("Length expected to be a multiple of 8, not %d" % (len(content), )) @@ -324,10 +328,14 @@ class VerifyLibxc(VerifyBase): """ Generic for all REC_TYPE_x86_pv_vcpu_{basic,extended,xsave,msrs} """ minsz = calcsize(X86_PV_VCPU_HDR_FORMAT) - if len(content) <= minsz: + if len(content) < minsz: raise RecordError("X86_PV_VCPU_%s record length must be at least %d" " bytes long" % (name, minsz)) + if len(content) == minsz: + self.info("Warning: X86_PV_VCPU_%s record with zero content" + % (name, )) + vcpuid, res1 = unpack(X86_PV_VCPU_HDR_FORMAT, content[:minsz]) if res1 != 0: @@ -385,6 +393,9 @@ class VerifyLibxc(VerifyBase): if rsvd != 0: raise RecordError("Reserved field not zero (0x%04x)" % (rsvd, )) + if count == 0: + self.info("Warning: HVM_PARAMS record with zero content") + sz += count * calcsize(HVM_PARAMS_ENTRY_FORMAT) if len(content) != sz: