From patchwork Wed May 11 21:06:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Richard W.M. Jones" X-Patchwork-Id: 9074651 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 10059BF29F for ; Wed, 11 May 2016 21:07:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7A39C20155 for ; Wed, 11 May 2016 21:07:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D3FE92014A for ; Wed, 11 May 2016 21:07:18 +0000 (UTC) Received: from localhost ([::1]:54098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0bLh-00054c-P7 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 11 May 2016 17:07:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0bLP-0004wa-Tk for qemu-devel@nongnu.org; Wed, 11 May 2016 17:07:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0bLN-0004Od-Jn for qemu-devel@nongnu.org; Wed, 11 May 2016 17:06:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33818) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0bLN-0004OT-DV for qemu-devel@nongnu.org; Wed, 11 May 2016 17:06:57 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0CD4663144; Wed, 11 May 2016 21:06:57 +0000 (UTC) Received: from moo.home.annexia.org (ovpn-204-25.brq.redhat.com [10.40.204.25]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4BL6me2023009; Wed, 11 May 2016 17:06:54 -0400 From: "Richard W.M. Jones" To: qemu-devel@nongnu.org Date: Wed, 11 May 2016 22:06:46 +0100 Message-Id: <1463000807-18015-3-git-send-email-rjones@redhat.com> In-Reply-To: <1463000807-18015-1-git-send-email-rjones@redhat.com> References: <1463000807-18015-1-git-send-email-rjones@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 11 May 2016 21:06:57 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v8 2/3] scripts/signrom.py: Check for magic in option ROMs. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marc.mari.barcelo@gmail.com, ehabkost@redhat.com, mst@redhat.com, stefanha@gmail.com, kraxel@redhat.com, pbonzini@redhat.com, lersek@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,FSL_HELO_HOME, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Because of the risk that compilers might not emit the asm() block at the beginning of the option ROM, check that the ROM contains the required magic signature. Signed-off-by: Richard W.M. Jones --- scripts/signrom.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/signrom.py b/scripts/signrom.py index 6c8b9bf..5629bca 100644 --- a/scripts/signrom.py +++ b/scripts/signrom.py @@ -17,7 +17,10 @@ if len(sys.argv) < 3: fin = open(sys.argv[1], 'rb') fout = open(sys.argv[2], 'wb') -fin.seek(2) +magic = fin.read(2) +if magic != '\x55\xaa': + sys.exit("%s: option ROM does not begin with magic 55 aa" % sys.argv[1]) + size_byte = ord(fin.read(1)) fin.seek(0)