From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 08/14] arm64: efi: split Image code and data into separate PE/COFF sections
Date: Fri, 10 Feb 2017 10:49:43 +0000 [thread overview]
Message-ID: <20170210104942.GF28753@leverpostej> (raw)
In-Reply-To: <1486554947-3964-9-git-send-email-ard.biesheuvel@linaro.org>
On Wed, Feb 08, 2017 at 11:55:41AM +0000, Ard Biesheuvel wrote:
> To prevent unintended modifications to the kernel text (malicious or
> otherwise) while running the EFI stub, describe the kernel image as
> two separate sections: a .text section with read-execute permissions,
> covering .text, .rodata and .init.text, and a .data section with
> read-write permissions, covering .init.data, .data and .bss.
>
> This relies on the firmware to actually take the section permission
> flags into account, but this is something that is currently being
> implemented in EDK2, which means we will likely start seeing it in
> the wild between one and two years from now.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
> index b8deffa9e1bf..a93cc2b6f50b 100644
> --- a/arch/arm64/kernel/vmlinux.lds.S
> +++ b/arch/arm64/kernel/vmlinux.lds.S
> @@ -149,6 +149,9 @@ SECTIONS
> ARM_EXIT_KEEP(EXIT_TEXT)
> }
>
> + . = ALIGN(SZ_4K);
> + __pecoff_data_start = .;
> +
I understand that the stub needs to split the init text/data since
unlike the kernel it'll map those with separate permissions, but it
feels odd to do this specifically for the EFI stub.
Yould it perhaps make more sense to always use separate segments for
init/exit text/data, and also apply the permission split in the kernel?
With that, I don't think we'd need additional stub-specific linker
script changes.
Thanks,
Mark.
> .init.data : {
> INIT_DATA
> INIT_SETUP(16)
> @@ -206,6 +209,7 @@ SECTIONS
> }
>
> PECOFF_EDATA_PADDING
> + __pecoff_data_rawsize = ABSOLUTE(. - __pecoff_data_start);
> _edata = .;
>
> BSS_SECTION(0, 0, 0)
> @@ -221,6 +225,7 @@ SECTIONS
> . += RESERVED_TTBR0_SIZE;
> #endif
>
> + __pecoff_data_size = ABSOLUTE(. - __pecoff_data_start);
> _end = .;
>
> STABS_DEBUG
> --
> 2.7.4
>
next prev parent reply other threads:[~2017-02-10 10:49 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-08 11:55 [PATCH v2 00/14] arm64+ARM: efi: PE/COFF cleanup/hardening Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 01/14] include: pe.h: allow for use in assembly Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 02/14] include: pe.h: add some missing definitions Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 03/14] arm64: efi: move EFI header and related data to a separate .S file Ard Biesheuvel
2017-02-10 10:10 ` Mark Rutland
2017-02-08 11:55 ` [PATCH v2 04/14] arm64: efi: clean up Image header after PE header has been split off Ard Biesheuvel
2017-02-10 10:11 ` Mark Rutland
2017-02-10 14:30 ` Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 05/14] arm64: efi: remove forbidden values from the PE/COFF header Ard Biesheuvel
2017-02-10 10:13 ` Mark Rutland
2017-02-10 14:31 ` Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 06/14] arm64: efi: remove pointless dummy .reloc section Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 07/14] arm64: efi: replace open coded constants with symbolic ones Ard Biesheuvel
2017-02-10 10:19 ` Mark Rutland
2017-02-08 11:55 ` [PATCH v2 08/14] arm64: efi: split Image code and data into separate PE/COFF sections Ard Biesheuvel
2017-02-10 10:49 ` Mark Rutland [this message]
2017-02-10 14:28 ` Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 09/14] arm: compressed: put zImage header and EFI header in dedicated section Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 10/14] arm: efi: remove forbidden values from the PE/COFF header Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 11/14] arm: efi: remove pointless dummy .reloc section Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 12/14] arm: efi: replace open coded constants with symbolic ones Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 13/14] arm: efi: split zImage code and data into separate PE/COFF sections Ard Biesheuvel
2017-02-08 11:55 ` [PATCH v2 14/14] arm: efi: add PE/COFF debug table to EFI header Ard Biesheuvel
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=20170210104942.GF28753@leverpostej \
--to=mark.rutland@arm.com \
--cc=linux-arm-kernel@lists.infradead.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