Message ID | c38ad7a1b89aff743d4a29882a7022d97d4fea58.1671098103.git.baskov@ispras.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp328010wrn; Thu, 15 Dec 2022 04:44:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf51egs+itBGDlV/dXwjA7mOmJMR5JREHcB7q3HTo1Wy4CG82XToE8HRrXncg0/OW80nojis X-Received: by 2002:a05:6402:370a:b0:461:2505:832d with SMTP id ek10-20020a056402370a00b004612505832dmr32610751edb.10.1671108247575; Thu, 15 Dec 2022 04:44:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671108247; cv=none; d=google.com; s=arc-20160816; b=qjMFu6P4E7c76JFKZCE7ZmSI6crBl8yn9OZOw7E3OBxQ7jU45rzYcqkLm9IdzW5B0S e0zjZF0NIAwvMbtV84AtV6WOEJxEs1fSV0jOJwML1+9x3cmimmS17VCDn9onc75Fnw/s pCRzluep+z4r8UMTJ3A1fyRqN3ZGFFzcVPoqE/NjG9W0BdE5wDfHx7JX705N51kh5ZSI AiQOg5I2h4BPEn+y4twyCSWLIOdM++Hy0+qBBC+BPa277f3kbEtOMO7PL4n/6ZAy4M5Z fkNr5M0sB+I13GGv2fCCzMOdYF/db6I57KZwWdK6L3EstlTgx9+pKvzmarl343sJ3Yep I1EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=IpU0tjNymTHz9fJiOLjTQ5CfC4DkOKpdBU+NiXX6lIQ=; b=WWRlo1VdOsvK8L+pdzcs372SEZf3qD0woKEJEhADE1p7f64uGO79ngUENyll4vQ0sZ oH9jr5Fn+knBiyXcOayYyU/YzVyYgsru+rLYObZKeMV9MF4GEGGhFK/ta+TZHsFK0Zfm 5QmYtJjqObd424Q8m9HS67TBJkKcPQ2v+bh+YSyrwGJB+CJi114BbdnWlXtBpfM/Ct36 L+UdRI7hPcno6HzPfnaQdbRJpQc71SKik4Rq0kcW0ondkkoZ+nulWpMwoBwjMoVQuy8k MpBd9e6JCJkq9tZSKnyKRgQucTU2qsE8fZj0OCM+0TIeUUZ77WiwTK2Gnar0bbM4IszQ OUAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=cEKjvhTi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020aa7c702000000b0046c46bc5c9csi13769962edq.327.2022.12.15.04.43.41; Thu, 15 Dec 2022 04:44:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=cEKjvhTi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229844AbiLOMnF (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Thu, 15 Dec 2022 07:43:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229806AbiLOMm2 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 15 Dec 2022 07:42:28 -0500 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D03DF06; Thu, 15 Dec 2022 04:42:28 -0800 (PST) Received: from localhost.localdomain (unknown [83.149.199.65]) by mail.ispras.ru (Postfix) with ESMTPSA id 365E140737A3; Thu, 15 Dec 2022 12:42:26 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 365E140737A3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1671108146; bh=IpU0tjNymTHz9fJiOLjTQ5CfC4DkOKpdBU+NiXX6lIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cEKjvhTiUKC/j3Emhuk9OQ4EdoQy7BjYYNtoIQbwX1GYrPCES0YmjcPMs/QlaqLTk yiffNspkkAAfp10zvnOms8EKuT/YwiYDDytk+5TO1hiWIvTjerfrP5EoZM7YMsQmhC Czbs+fvh7m+unlip1AyPmssh7gW2kpmQTdWwvtFU= From: Evgeniy Baskov <baskov@ispras.ru> To: Ard Biesheuvel <ardb@kernel.org> Cc: Evgeniy Baskov <baskov@ispras.ru>, Borislav Petkov <bp@alien8.de>, Andy Lutomirski <luto@kernel.org>, Dave Hansen <dave.hansen@linux.intel.com>, Ingo Molnar <mingo@redhat.com>, Peter Zijlstra <peterz@infradead.org>, Thomas Gleixner <tglx@linutronix.de>, Alexey Khoroshilov <khoroshilov@ispras.ru>, Peter Jones <pjones@redhat.com>, "Limonciello, Mario" <mario.limonciello@amd.com>, joeyli <jlee@suse.com>, lvc-project@linuxtesting.org, x86@kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v4 21/26] efi/x86: Explicitly set sections memory attributes Date: Thu, 15 Dec 2022 15:38:12 +0300 Message-Id: <c38ad7a1b89aff743d4a29882a7022d97d4fea58.1671098103.git.baskov@ispras.ru> X-Mailer: git-send-email 2.37.4 In-Reply-To: <cover.1671098103.git.baskov@ispras.ru> References: <cover.1671098103.git.baskov@ispras.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752284001603129316?= X-GMAIL-MSGID: =?utf-8?q?1752284001603129316?= |
Series |
x86_64: Improvements at compressed kernel stage
|
|
Commit Message
Evgeniy Baskov
Dec. 15, 2022, 12:38 p.m. UTC
Explicitly change sections memory attributes in efi_pe_entry in case of incorrect EFI implementations and to reduce access rights to compressed kernel blob. By default it is set executable due to restriction in maximum number of sections that can fit before zero page. Tested-by: Peter Jones <pjones@redhat.com> Signed-off-by: Evgeniy Baskov <baskov@ispras.ru> --- drivers/firmware/efi/libstub/x86-stub.c | 54 +++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
Comments
On Thu, 15 Dec 2022 at 13:42, Evgeniy Baskov <baskov@ispras.ru> wrote: > > Explicitly change sections memory attributes in efi_pe_entry in case > of incorrect EFI implementations and to reduce access rights to > compressed kernel blob. By default it is set executable due to > restriction in maximum number of sections that can fit before zero > page. > > Tested-by: Peter Jones <pjones@redhat.com> > Signed-off-by: Evgeniy Baskov <baskov@ispras.ru> I don't think we need this patch. Firmware that cares about W^X will map the PE image with R-X for text/rodata and RW- for data/bss, which is sufficient, and firmware that doesn't is a lost cause anyway. > --- > drivers/firmware/efi/libstub/x86-stub.c | 54 +++++++++++++++++++++++++ > 1 file changed, 54 insertions(+) > > diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c > index 1f0a2e7075c3..60697fcd8950 100644 > --- a/drivers/firmware/efi/libstub/x86-stub.c > +++ b/drivers/firmware/efi/libstub/x86-stub.c > @@ -27,6 +27,12 @@ const efi_dxe_services_table_t *efi_dxe_table; > u32 image_offset __section(".data"); > static efi_loaded_image_t *image __section(".data"); > > +extern char _head[], _ehead[]; > +extern char _compressed[], _ecompressed[]; > +extern char _text[], _etext[]; > +extern char _rodata[], _erodata[]; > +extern char _data[]; > + > static efi_status_t > preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) > { > @@ -343,6 +349,52 @@ void __noreturn efi_exit(efi_handle_t handle, efi_status_t status) > asm("hlt"); > } > > + > +/* > + * Manually setup memory protection attributes for each ELF section > + * since we cannot do it properly by using PE sections. > + */ > +static void setup_sections_memory_protection(unsigned long image_base) > +{ > +#ifdef CONFIG_EFI_DXE_MEM_ATTRIBUTES > + efi_dxe_table = get_efi_config_table(EFI_DXE_SERVICES_TABLE_GUID); > + > + if (!efi_dxe_table || > + efi_dxe_table->hdr.signature != EFI_DXE_SERVICES_TABLE_SIGNATURE) { > + efi_warn("Unable to locate EFI DXE services table\n"); > + efi_dxe_table = NULL; > + return; > + } > + > + /* .setup [image_base, _head] */ > + efi_adjust_memory_range_protection(image_base, > + (unsigned long)_head - image_base, > + EFI_MEMORY_RO | EFI_MEMORY_XP); > + /* .head.text [_head, _ehead] */ > + efi_adjust_memory_range_protection((unsigned long)_head, > + (unsigned long)_ehead - (unsigned long)_head, > + EFI_MEMORY_RO); > + /* .rodata..compressed [_compressed, _ecompressed] */ > + efi_adjust_memory_range_protection((unsigned long)_compressed, > + (unsigned long)_ecompressed - (unsigned long)_compressed, > + EFI_MEMORY_RO | EFI_MEMORY_XP); > + /* .text [_text, _etext] */ > + efi_adjust_memory_range_protection((unsigned long)_text, > + (unsigned long)_etext - (unsigned long)_text, > + EFI_MEMORY_RO); > + /* .rodata [_rodata, _erodata] */ > + efi_adjust_memory_range_protection((unsigned long)_rodata, > + (unsigned long)_erodata - (unsigned long)_rodata, > + EFI_MEMORY_RO | EFI_MEMORY_XP); > + /* .data, .bss [_data, _end] */ > + efi_adjust_memory_range_protection((unsigned long)_data, > + (unsigned long)_end - (unsigned long)_data, > + EFI_MEMORY_XP); > +#else > + (void)image_base; > +#endif > +} > + > void __noreturn efi_stub_entry(efi_handle_t handle, > efi_system_table_t *sys_table_arg, > struct boot_params *boot_params); > @@ -687,6 +739,8 @@ asmlinkage unsigned long efi_main(efi_handle_t handle, > efi_dxe_table = NULL; > } > > + setup_sections_memory_protection(bzimage_addr - image_offset); > + > #ifdef CONFIG_CMDLINE_BOOL > status = efi_parse_options(CONFIG_CMDLINE); > if (status != EFI_SUCCESS) { > -- > 2.37.4 >
On 2023-03-10 18:20, Ard Biesheuvel wrote: > On Thu, 15 Dec 2022 at 13:42, Evgeniy Baskov <baskov@ispras.ru> wrote: >> >> Explicitly change sections memory attributes in efi_pe_entry in case >> of incorrect EFI implementations and to reduce access rights to >> compressed kernel blob. By default it is set executable due to >> restriction in maximum number of sections that can fit before zero >> page. >> >> Tested-by: Peter Jones <pjones@redhat.com> >> Signed-off-by: Evgeniy Baskov <baskov@ispras.ru> > > I don't think we need this patch. Firmware that cares about W^X will > map the PE image with R-X for text/rodata and RW- for data/bss, which > is sufficient, and firmware that doesn't is a lost cause anyway. This patch were here mainly here to make .rodata non-executable and for the UEFI handover protocol, for which attributes are usually not getting applied. Since the UEFI handover protocol is deprecated, I'll exclude patches from v5 and maybe submit it separately modified to apply attributes only when booting via this protocol. > > >> --- >> drivers/firmware/efi/libstub/x86-stub.c | 54 >> +++++++++++++++++++++++++ >> 1 file changed, 54 insertions(+) >> >> diff --git a/drivers/firmware/efi/libstub/x86-stub.c >> b/drivers/firmware/efi/libstub/x86-stub.c >> index 1f0a2e7075c3..60697fcd8950 100644 >> --- a/drivers/firmware/efi/libstub/x86-stub.c >> +++ b/drivers/firmware/efi/libstub/x86-stub.c >> @@ -27,6 +27,12 @@ const efi_dxe_services_table_t *efi_dxe_table; >> u32 image_offset __section(".data"); >> static efi_loaded_image_t *image __section(".data"); >> >> +extern char _head[], _ehead[]; >> +extern char _compressed[], _ecompressed[]; >> +extern char _text[], _etext[]; >> +extern char _rodata[], _erodata[]; >> +extern char _data[]; >> + >> static efi_status_t >> preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct >> pci_setup_rom **__rom) >> { >> @@ -343,6 +349,52 @@ void __noreturn efi_exit(efi_handle_t handle, >> efi_status_t status) >> asm("hlt"); >> } >> >> + >> +/* >> + * Manually setup memory protection attributes for each ELF section >> + * since we cannot do it properly by using PE sections. >> + */ >> +static void setup_sections_memory_protection(unsigned long >> image_base) >> +{ >> +#ifdef CONFIG_EFI_DXE_MEM_ATTRIBUTES >> + efi_dxe_table = >> get_efi_config_table(EFI_DXE_SERVICES_TABLE_GUID); >> + >> + if (!efi_dxe_table || >> + efi_dxe_table->hdr.signature != >> EFI_DXE_SERVICES_TABLE_SIGNATURE) { >> + efi_warn("Unable to locate EFI DXE services table\n"); >> + efi_dxe_table = NULL; >> + return; >> + } >> + >> + /* .setup [image_base, _head] */ >> + efi_adjust_memory_range_protection(image_base, >> + (unsigned long)_head - >> image_base, >> + EFI_MEMORY_RO | >> EFI_MEMORY_XP); >> + /* .head.text [_head, _ehead] */ >> + efi_adjust_memory_range_protection((unsigned long)_head, >> + (unsigned long)_ehead - >> (unsigned long)_head, >> + EFI_MEMORY_RO); >> + /* .rodata..compressed [_compressed, _ecompressed] */ >> + efi_adjust_memory_range_protection((unsigned long)_compressed, >> + (unsigned long)_ecompressed >> - (unsigned long)_compressed, >> + EFI_MEMORY_RO | >> EFI_MEMORY_XP); >> + /* .text [_text, _etext] */ >> + efi_adjust_memory_range_protection((unsigned long)_text, >> + (unsigned long)_etext - >> (unsigned long)_text, >> + EFI_MEMORY_RO); >> + /* .rodata [_rodata, _erodata] */ >> + efi_adjust_memory_range_protection((unsigned long)_rodata, >> + (unsigned long)_erodata - >> (unsigned long)_rodata, >> + EFI_MEMORY_RO | >> EFI_MEMORY_XP); >> + /* .data, .bss [_data, _end] */ >> + efi_adjust_memory_range_protection((unsigned long)_data, >> + (unsigned long)_end - >> (unsigned long)_data, >> + EFI_MEMORY_XP); >> +#else >> + (void)image_base; >> +#endif >> +} >> + >> void __noreturn efi_stub_entry(efi_handle_t handle, >> efi_system_table_t *sys_table_arg, >> struct boot_params *boot_params); >> @@ -687,6 +739,8 @@ asmlinkage unsigned long efi_main(efi_handle_t >> handle, >> efi_dxe_table = NULL; >> } >> >> + setup_sections_memory_protection(bzimage_addr - image_offset); >> + >> #ifdef CONFIG_CMDLINE_BOOL >> status = efi_parse_options(CONFIG_CMDLINE); >> if (status != EFI_SUCCESS) { >> -- >> 2.37.4 >>
On Sat, 11 Mar 2023 at 16:09, Evgeniy Baskov <baskov@ispras.ru> wrote: > > On 2023-03-10 18:20, Ard Biesheuvel wrote: > > On Thu, 15 Dec 2022 at 13:42, Evgeniy Baskov <baskov@ispras.ru> wrote: > >> > >> Explicitly change sections memory attributes in efi_pe_entry in case > >> of incorrect EFI implementations and to reduce access rights to > >> compressed kernel blob. By default it is set executable due to > >> restriction in maximum number of sections that can fit before zero > >> page. > >> > >> Tested-by: Peter Jones <pjones@redhat.com> > >> Signed-off-by: Evgeniy Baskov <baskov@ispras.ru> > > > > I don't think we need this patch. Firmware that cares about W^X will > > map the PE image with R-X for text/rodata and RW- for data/bss, which > > is sufficient, and firmware that doesn't is a lost cause anyway. > > This patch were here mainly here to make .rodata non-executable and for > the UEFI handover protocol, for which attributes are usually not getting > applied. > > Since the UEFI handover protocol is deprecated, I'll exclude patches > from > v5 and maybe submit it separately modified to apply attributes only when > booting via this protocol. > I think the issue here is that loaders that use the UEFI handover protocol use their own implementations of LoadImage/StartImage as well, and some of those tend to do little more than copy the image into memory and jump to the EFI handover protocol entry point, without even accounting for the image size in memory or clearing the bss. To be honest, even though I understand the reason these had to be implemented, I'm a bit reluctant to cater for the needs of such loaders, given that these are all downstream distro forks of GRUB (with shim) with varying levels of adherence to the PE/COFF spec. I'm happy to revisit this later if others feel this is important, but for the moment, I'd prefer it if we could focus on making the x86 image work better with compliant loaders, which is what this series is primarily about.
On 2023-03-11 20:39, Ard Biesheuvel wrote: > On Sat, 11 Mar 2023 at 16:09, Evgeniy Baskov <baskov@ispras.ru> wrote: >> >> On 2023-03-10 18:20, Ard Biesheuvel wrote: >> > On Thu, 15 Dec 2022 at 13:42, Evgeniy Baskov <baskov@ispras.ru> wrote: >> >> >> >> Explicitly change sections memory attributes in efi_pe_entry in case >> >> of incorrect EFI implementations and to reduce access rights to >> >> compressed kernel blob. By default it is set executable due to >> >> restriction in maximum number of sections that can fit before zero >> >> page. >> >> >> >> Tested-by: Peter Jones <pjones@redhat.com> >> >> Signed-off-by: Evgeniy Baskov <baskov@ispras.ru> >> > >> > I don't think we need this patch. Firmware that cares about W^X will >> > map the PE image with R-X for text/rodata and RW- for data/bss, which >> > is sufficient, and firmware that doesn't is a lost cause anyway. >> >> This patch were here mainly here to make .rodata non-executable and >> for >> the UEFI handover protocol, for which attributes are usually not >> getting >> applied. >> >> Since the UEFI handover protocol is deprecated, I'll exclude patches >> from >> v5 and maybe submit it separately modified to apply attributes only >> when >> booting via this protocol. >> > > I think the issue here is that loaders that use the UEFI handover > protocol use their own implementations of LoadImage/StartImage as > well, and some of those tend to do little more than copy the image > into memory and jump to the EFI handover protocol entry point, without > even accounting for the image size in memory or clearing the bss. > AFAIK this patch does not break loaders that load PE image as a flat binary, since it only operates on ELF sections that are mapped 1-to-1. But that's just the note for a future. > To be honest, even though I understand the reason these had to be > implemented, I'm a bit reluctant to cater for the needs of such > loaders, given that these are all downstream distro forks of GRUB > (with shim) with varying levels of adherence to the PE/COFF spec. > > I'm happy to revisit this later if others feel this is important, but > for the moment, I'd prefer it if we could focus on making the x86 > image work better with compliant loaders, which is what this series is > primarily about. That's very reasonable. I'll put this patch aside for now then.
diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c index 1f0a2e7075c3..60697fcd8950 100644 --- a/drivers/firmware/efi/libstub/x86-stub.c +++ b/drivers/firmware/efi/libstub/x86-stub.c @@ -27,6 +27,12 @@ const efi_dxe_services_table_t *efi_dxe_table; u32 image_offset __section(".data"); static efi_loaded_image_t *image __section(".data"); +extern char _head[], _ehead[]; +extern char _compressed[], _ecompressed[]; +extern char _text[], _etext[]; +extern char _rodata[], _erodata[]; +extern char _data[]; + static efi_status_t preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) { @@ -343,6 +349,52 @@ void __noreturn efi_exit(efi_handle_t handle, efi_status_t status) asm("hlt"); } + +/* + * Manually setup memory protection attributes for each ELF section + * since we cannot do it properly by using PE sections. + */ +static void setup_sections_memory_protection(unsigned long image_base) +{ +#ifdef CONFIG_EFI_DXE_MEM_ATTRIBUTES + efi_dxe_table = get_efi_config_table(EFI_DXE_SERVICES_TABLE_GUID); + + if (!efi_dxe_table || + efi_dxe_table->hdr.signature != EFI_DXE_SERVICES_TABLE_SIGNATURE) { + efi_warn("Unable to locate EFI DXE services table\n"); + efi_dxe_table = NULL; + return; + } + + /* .setup [image_base, _head] */ + efi_adjust_memory_range_protection(image_base, + (unsigned long)_head - image_base, + EFI_MEMORY_RO | EFI_MEMORY_XP); + /* .head.text [_head, _ehead] */ + efi_adjust_memory_range_protection((unsigned long)_head, + (unsigned long)_ehead - (unsigned long)_head, + EFI_MEMORY_RO); + /* .rodata..compressed [_compressed, _ecompressed] */ + efi_adjust_memory_range_protection((unsigned long)_compressed, + (unsigned long)_ecompressed - (unsigned long)_compressed, + EFI_MEMORY_RO | EFI_MEMORY_XP); + /* .text [_text, _etext] */ + efi_adjust_memory_range_protection((unsigned long)_text, + (unsigned long)_etext - (unsigned long)_text, + EFI_MEMORY_RO); + /* .rodata [_rodata, _erodata] */ + efi_adjust_memory_range_protection((unsigned long)_rodata, + (unsigned long)_erodata - (unsigned long)_rodata, + EFI_MEMORY_RO | EFI_MEMORY_XP); + /* .data, .bss [_data, _end] */ + efi_adjust_memory_range_protection((unsigned long)_data, + (unsigned long)_end - (unsigned long)_data, + EFI_MEMORY_XP); +#else + (void)image_base; +#endif +} + void __noreturn efi_stub_entry(efi_handle_t handle, efi_system_table_t *sys_table_arg, struct boot_params *boot_params); @@ -687,6 +739,8 @@ asmlinkage unsigned long efi_main(efi_handle_t handle, efi_dxe_table = NULL; } + setup_sections_memory_protection(bzimage_addr - image_offset); + #ifdef CONFIG_CMDLINE_BOOL status = efi_parse_options(CONFIG_CMDLINE); if (status != EFI_SUCCESS) {