Re: [PATCH v5 02/27] x86/build: Remove RWX sections and align on 4KB
From: Borislav Petkov
Date: Wed Apr 05 2023 - 13:41:53 EST
On Tue, Mar 14, 2023 at 01:13:29PM +0300, Evgeniy Baskov wrote:
> Avoid creating sections simultaneously writable and readable to prepare
> for W^X implementation for the kernel itself (not the decompressor).
> Align kernel sections on page size (4KB) to allow protecting them in the
> page tables.
>
> Split init code form ".init" segment into separate R_X ".inittext"
s/form/from/
> segment and make ".init" segment non-executable.
"... and make the .init segment RW_."
> Also add these segments to x86_32 architecture for consistency.
Same comment as before: please refrain from talking about the *what* in
a commit message but about the *why*.
And considering the matter, you have a *lot* of *why* to talk about. :-)
Pls check your whole set.
> Currently paging is disabled in x86_32 in compressed kernel, so
> protection is not applied anyways, but .init code was incorrectly
> placed in non-executable ".data" segment. This should not change
> anything meaningful in memory layout now, but might be required in case
> memory protection will also be implemented in compressed kernel for
> x86_32.
I highly doubt that - no one cares about 32-bit x86 anymore.
> @@ -226,9 +225,10 @@ SECTIONS
> #endif
>
> INIT_TEXT_SECTION(PAGE_SIZE)
> -#ifdef CONFIG_X86_64
> - :init
> -#endif
> + :inittext
> +
> + . = ALIGN(PAGE_SIZE);
> +
>
> /*
> * Section for code used exclusively before alternatives are run. All
> @@ -240,6 +240,7 @@ SECTIONS
> .altinstr_aux : AT(ADDR(.altinstr_aux) - LOAD_OFFSET) {
> *(.altinstr_aux)
> }
> + :init
Why isn't this placed after inittext but here?
I'm thinking you wanna have:
:inittext
. = ALIGN..
:init
<rest>
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette