From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1oObKa-0006P3-EH for mharc-grub-devel@gnu.org; Thu, 18 Aug 2022 04:56:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oObJw-0006FE-L7 for grub-devel@gnu.org; Thu, 18 Aug 2022 04:56:11 -0400 Received: from ams.source.kernel.org ([145.40.68.75]:35474) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oObJp-00019M-TI for grub-devel@gnu.org; Thu, 18 Aug 2022 04:56:07 -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 ams.source.kernel.org (Postfix) with ESMTPS id 6EEBCB81DEB; Thu, 18 Aug 2022 08:55:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03D2DC433C1; Thu, 18 Aug 2022 08:55:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660812955; bh=UUvKXR2cO27YDKET1AyG/i9gzYw04CdLto0thocEz2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eZ3+lreY6dvpCx5DNQhI9brjoeeNla8/nRGqDU9UG+xKbVMdmoq7lgGU9JI1nJP3+ YURN7Wgs+A4qn58Pi+NbJdAglfTwWEMa+0db8JEct+53GwqhuC8NeWUt6RjT+mcb0D jLiKePwk35+w6JPse7DYfwo3ttn24NKJ++n4XhHRWR1r/kHRP/XrRQ63uvaMpAW4uD P1F+/ctW4dNzV+jlv8sHlHOWEd7JKKNzP/GIgw9KGheNIXBQMAPJoWrLSaYpN+Cpk1 SDsM/1Lg4x2asqITaqvrTQZ+6KlAZIzruuL+RaN46FHqugrb0mJCsQdia/GhPfV5GG Lm5u45yo1dBDg== From: Ard Biesheuvel To: grub-devel@nongnu.org Cc: linux-efi@vger.kernel.org, Ard Biesheuvel , grub-devel@gnu.org, Daniel Kiper , Nikita Ermakov , Atish Patra , Huacai Chen , Heinrich Schuchardt , dann frazier , Julian Andres Klode Subject: [PATCH resend 3/9] arm64/linux: Remove magic number header field check Date: Thu, 18 Aug 2022 10:55:33 +0200 Message-Id: <20220818085540.2075028-4-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220818085540.2075028-1-ardb@kernel.org> References: <20220818085540.2075028-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2374; i=ardb@kernel.org; h=from:subject; bh=UUvKXR2cO27YDKET1AyG/i9gzYw04CdLto0thocEz2Y=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBi/f59S2E/1h05DNgErqGpeX5fGPw91TcV1H2M0xeP qWzAX1OJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYv3+fQAKCRDDTyI5ktmPJGuIC/ 48Idyt81w/P+gZvj7mywXsJSt2MW0nB7uxRn0sr6qZoegCyZWFJ0zejv4QIQjevXqM/tTI5byTqZUF wNPAdrsqcvDj9Ibd7tOrXuFTZZStPMdyd1ZuMSIuEEb5VtJe1Sxd9O+H9BiAhch9PR6SN99LtgdMu8 fCBFpoh5K44L0XBDDTtO0wnA1V4Lq9n0Kzb1o4r9KEL9IS1nB9RtEd02i8BLQyt3Ntbz0sqMIdmdYW kMGfNuYXjT5uC0ssvt4G331s5lB7/GRoSqjuCHEr5mtCe+DEJ1GGC66Ed06w0WTVIXizNfwDKQq9Ni 7bp0HLGpGXHGabpjfP79oJqhrqyZabjGlFHSUa3S3a/DwFxaNJkmoUL0g3/3SmjJcKP59/9IVfIxjb XH+Vun9iOXCTUhL2ELVpMWydSEdtOJEcpMhb6mnkdy/iZxe4ORB3MwFyoFIbF9mrUrWtG98rxHruma hc0n09nc5Hs0SSuDJYqO8p86KEydddWp7Fg7IwtU28HTY= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=145.40.68.75; envelope-from=ardb@kernel.org; helo=ams.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, 18 Aug 2022 08:56:13 -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 --- include/grub/arm/linux.h | 1 - include/grub/arm64/linux.h | 1 - 3 files changed, 5 deletions(-) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index aed7a200b848..b5b559c236e0 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")); diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index bcd5a7eb186e..bfab334dd87f 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -35,7 +35,6 @@ struct linux_arm_kernel_header { }; #if defined(__arm__) -# define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM_MAGIC_SIGNATURE # define linux_arch_kernel_header linux_arm_kernel_header #endif diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h index 7e22b4ab6990..96f1494e05a2 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -39,7 +39,6 @@ struct linux_arm64_kernel_header }; #if defined(__aarch64__) -# define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM64_MAGIC_SIGNATURE # define linux_arch_kernel_header linux_arm64_kernel_header #endif -- 2.35.1