From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1oM9Xf-0007Zn-Du for mharc-grub-devel@gnu.org; Thu, 11 Aug 2022 10:52:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9Xd-0007Wy-OH for grub-devel@gnu.org; Thu, 11 Aug 2022 10:52:09 -0400 Received: from dfw.source.kernel.org ([139.178.84.217]:58286) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9Xb-0001sA-VK for grub-devel@gnu.org; Thu, 11 Aug 2022 10:52:09 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1A50361547; Thu, 11 Aug 2022 14:52:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A7A8C433D7; Thu, 11 Aug 2022 14:52:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660229524; bh=ZeXm80HFuVEMhgIFHbVOMl4kIdO+nl/dXmzVPtdURQg=; h=From:To:Cc:Subject:Date:From; b=RoPCb1JcFC9mmdBODm2ot5kiTbmR2Ql98rcc7VcY3CqUgvFCOQv72raNz65ntGiRk zn/7kGI0hTTN2xeqbjFhAvWsGf2ImhPdxU+Ja6sO3wYioBRk2tYQC+rl2NloiCS7fZ 716+//XWbqTBi8Gu6InMZB7XpqBK7f7hL27PIzVdh4eF0RpRIukgA7urxsYcSUJi3I w/W0Wjs4oLtk8vySB5NGOCWTl3CbZN6rsrAlpcHsZgjYvP+Tnb1N22csPaWfdtJlz2 BI5KFZ9ZmScklbM3A3Xtxrg4c8QntJ1AYl0T8S7M6GDeeCv3nVq8HX+CWUkik4v8Kf Uaou5ONdqocng== From: Ard Biesheuvel To: grub-devel@gnu.org Cc: daniel.kiper@oracle.com, linux-efi@vger.kernel.org, Ard Biesheuvel Subject: [PATCH] arm64/linux: Remove magic number header field check Date: Thu, 11 Aug 2022 16:51:57 +0200 Message-Id: <20220811145157.3237840-1-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=139.178.84.217; envelope-from=ardb@kernel.org; helo=dfw.source.kernel.org X-Spam_score_int: -71 X-Spam_score: -7.2 X-Spam_bar: ------- X-Spam_report: (-7.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2022 14:52:10 -0000 The 'ARM\x64' magic number in the file header identifies an image as one that implements the bare metal boot protocol, allowing the loader to simply move the file to a suitably aligned address in memory, with sufficient headroom for the trailing .bss segment (the required memory size is described in the header as well). Note of this matters for GRUB, as it only supports EFI boot. EFI does not care about this magic number, and nor should GRUB: this prevents us from booting other PE linux images, such as the generic EFI zboot decompressor, which is a pure PE/COFF image, and does not implement the bare metal boot protocol. So drop the magic number check. Signed-off-by: Ard Biesheuvel --- grub-core/loader/arm64/linux.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index ef3e9f9444ca..4c92e48ac91c 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -51,9 +51,6 @@ static grub_addr_t initrd_end; grub_err_t grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh) { - if (lh->magic != GRUB_LINUX_ARMXX_MAGIC_SIGNATURE) - return grub_error(GRUB_ERR_BAD_OS, "invalid magic number"); - if ((lh->code0 & 0xffff) != GRUB_PE32_MAGIC) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled")); -- 2.35.1