From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
To: Alexandre Ghiti <alex@ghiti.fr>
Cc: Ard Biesheuvel <ardb@kernel.org>,
Emil Renner Berthing <emil.renner.berthing@canonical.com>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>
Subject: Re: [PATCH 1/1] riscv: efi: Set NX compat flag in PE/COFF header
Date: Tue, 1 Oct 2024 17:24:21 +0200 [thread overview]
Message-ID: <811ea10e-3bf1-45a5-a407-c09ec5756b48@canonical.com> (raw)
In-Reply-To: <3c2ff70d-a580-4bba-b6e2-1b66b0a98c5d@ghiti.fr>
On 01.10.24 15:51, Alexandre Ghiti wrote:
> Hi Heinrich,
>
> On 29/09/2024 16:02, Heinrich Schuchardt wrote:
>> The IMAGE_DLLCHARACTERISTICS_NX_COMPAT informs the firmware that the
>> EFI binary does not rely on pages that are both executable and
>> writable.
>>
>> The flag is used by some distro versions of GRUB to decide if the EFI
>> binary may be executed.
>>
>> As the Linux kernel neither has RWX sections nor needs RWX pages for
>> relocation we should set the flag.
>>
>> Cc: Ard Biesheuvel <ardb@kernel.org>
>> Cc: <stable@vger.kernel.org>
>> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
>> ---
>> arch/riscv/kernel/efi-header.S | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/kernel/efi-header.S b/arch/riscv/kernel/efi-
>> header.S
>> index 515b2dfbca75..c5f17c2710b5 100644
>> --- a/arch/riscv/kernel/efi-header.S
>> +++ b/arch/riscv/kernel/efi-header.S
>> @@ -64,7 +64,7 @@ extra_header_fields:
>> .long efi_header_end - _start // SizeOfHeaders
>> .long 0 // CheckSum
>> .short IMAGE_SUBSYSTEM_EFI_APPLICATION // Subsystem
>> - .short 0 // DllCharacteristics
>> + .short IMAGE_DLL_CHARACTERISTICS_NX_COMPAT //
>> DllCharacteristics
>> .quad 0 // SizeOfStackReserve
>> .quad 0 // SizeOfStackCommit
>> .quad 0 // SizeOfHeapReserve
>
>
> I don't understand if this fixes something or not: what could go wrong
> if we don't do this?
>
> Thanks,
>
> Alex
>
Hello Alexandre,
https://learn.microsoft.com/en-us/windows-hardware/drivers/bringup/uefi-ca-memory-mitigation-requirements
describes Microsoft's effort to improve security by avoiding memory
pages that are both executable and writable.
IMAGE_DLL_CHARACTERISTICS_NX_COMPAT is an assertion by the EFI binary
that it does not use RWX pages. It may use the
EFI_MEMORY_ATTRIBUTE_PROTOCOL to set whether a page is writable or
executable (but not both).
When using secure boot, compliant firmware will not allow loading a
binary if the flag is not set.
Best regards
Heinrich
next prev parent reply other threads:[~2024-10-01 15:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-29 14:02 [PATCH 1/1] riscv: efi: Set NX compat flag in PE/COFF header Heinrich Schuchardt
2024-10-01 10:56 ` Emil Renner Berthing
2024-10-01 13:51 ` Alexandre Ghiti
2024-10-01 15:24 ` Heinrich Schuchardt [this message]
2024-10-09 7:34 ` Alexandre Ghiti
2024-10-09 7:47 ` Heinrich Schuchardt
2024-10-09 7:52 ` Alexandre Ghiti
2024-10-09 7:38 ` Ard Biesheuvel
2024-10-17 16:30 ` patchwork-bot+linux-riscv
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=811ea10e-3bf1-45a5-a407-c09ec5756b48@canonical.com \
--to=heinrich.schuchardt@canonical.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=ardb@kernel.org \
--cc=emil.renner.berthing@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox