From patchwork Thu Jul 21 17:17:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9242075 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 A6251607D3 for ; Thu, 21 Jul 2016 17:20:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94555254F7 for ; Thu, 21 Jul 2016 17:20:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8932527D64; Thu, 21 Jul 2016 17:20:32 +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 164AA254F7 for ; Thu, 21 Jul 2016 17:20:32 +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 1bQHbY-0003mB-6Q; Thu, 21 Jul 2016 17:17:48 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bQHbW-0003la-Nm for xen-devel@lists.xen.org; Thu, 21 Jul 2016 17:17:46 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 70/BB-09160-AB301975; Thu, 21 Jul 2016 17:17:46 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplkeJIrShJLcpLzFFi42JxWrohUncn88R wg0evtSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oyHy16yF5wVqFj9/jZTA+NCni5GTg4JAX+J T+2zGEFsNgF9id0vPjGB2CIC6hKnOy6ygtjMAmUSUye9Zu5i5OAQFkiQ6L6jCxJmEVCVmPJlI juIzSvgLrH0+SIWiJFyEueP/wQr5xTwkJh0IwQkLARUsnVXIxOErSZxrf8SVKugxMmZT1ggNk lIHHzxAqxVQoBb4m+3/QRGvllIqmYhqVrAyLSKUb04tagstUjXUi+pKDM9oyQ3MTNH19DAWC8 3tbg4MT01JzGpWC85P3cTIzCY6hkYGHcwvv7pdIhRkoNJSZT37eQJ4UJ8SfkplRmJxRnxRaU5 qcWHGGU4OJQkeD2ZJoYLCRalpqdWpGXmAMMaJi3BwaMkwtsAkuYtLkjMLc5Mh0idYlSUEuedA JIQAElklObBtcFi6RKjrJQwLyMDA4MQT0FqUW5mCar8K0ZxDkYlYd75IFN4MvNK4Ka/AlrMBL R4jkA/yOKSRISUVANjRVG41FfHwCuNNzlWOC3z2yy15XNmz51gYxPG45kzJlvK3L/lu7vt9T4 Z80t1789IhsyQaWTeH+Imp6Xhf20Db73UOtkITq3Ct0za4SnT7+4yvPV40ZaUWoX3Nh/fLY3r 8ueKVuOUPnKUq0vyreR6+zUs69TtbjG5O9rU/rDn5vgX9NHgUawSS3FGoqEWc1FxIgAZvRzio AIAAA== X-Env-Sender: prvs=003bda41c=Andrew.Cooper3@citrix.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1469121459!51172737!4 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 12980 invoked from network); 21 Jul 2016 17:17:45 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-13.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 21 Jul 2016 17:17:45 -0000 X-IronPort-AV: E=Sophos;i="5.28,400,1464652800"; d="scan'208";a="367619782" From: Andrew Cooper To: Xen-devel Date: Thu, 21 Jul 2016 18:17:37 +0100 Message-ID: <1469121457-365-5-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1469121457-365-1-git-send-email-andrew.cooper3@citrix.com> References: <1469121457-365-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Andrew Cooper , Ian Jackson , Wei Liu Subject: [Xen-devel] [PATCH 4/4] tools/python: Adjust migration v2 library to warn about zero-length 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: Wei Liu --- 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 85a78f4..2037c85 100644 --- a/tools/python/xen/migration/libxc.py +++ b/tools/python/xen/migration/libxc.py @@ -308,6 +308,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), )) @@ -320,10 +324,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: @@ -381,6 +389,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: