From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 5/5] arm64: mmu: apply strict permissions to .init.text and .init.data
Date: Tue, 14 Feb 2017 15:57:27 +0000 [thread overview]
Message-ID: <20170214155727.GF23718@leverpostej> (raw)
In-Reply-To: <1486844586-26135-6-git-send-email-ard.biesheuvel@linaro.org>
On Sat, Feb 11, 2017 at 08:23:06PM +0000, Ard Biesheuvel wrote:
> To avoid having mappings that are writable and executable at the same
> time, split the init region into a .init.text region that is mapped
> read-only, and a .init.data region that is mapped non-executable.
>
> This is possible now that the alternative patching occurs via the linear
> mapping, and the linear alias of the init region is always mapped writable
> (but never executable).
>
> Since the alternatives descriptions themselves are read-only data, move
> those into the .init.text region.
>
> Reviewed-by: Laura Abbott <labbott@redhat.com>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
This generally looks good.
As with my comment on patch 4, we might want to allow .init.text to be
mapped writeable for the sake of external debuggers.
Thanks,
Mark.
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index e97f1ce967ec..c53c43b4ed3f 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -479,12 +479,16 @@ static void __init map_kernel_segment(pgd_t *pgd, void *va_start, void *va_end,
> */
> static void __init map_kernel(pgd_t *pgd)
> {
> - static struct vm_struct vmlinux_text, vmlinux_rodata, vmlinux_init, vmlinux_data;
> + static struct vm_struct vmlinux_text, vmlinux_rodata, vmlinux_inittext,
> + vmlinux_initdata, vmlinux_data;
>
> map_kernel_segment(pgd, _text, _etext, PAGE_KERNEL_ROX, &vmlinux_text);
> - map_kernel_segment(pgd, __start_rodata, __init_begin, PAGE_KERNEL, &vmlinux_rodata);
> - map_kernel_segment(pgd, __init_begin, __init_end, PAGE_KERNEL_EXEC,
> - &vmlinux_init);
> + map_kernel_segment(pgd, __start_rodata, __inittext_begin, PAGE_KERNEL,
> + &vmlinux_rodata);
> + map_kernel_segment(pgd, __inittext_begin, __inittext_end, PAGE_KERNEL_ROX,
> + &vmlinux_inittext);
> + map_kernel_segment(pgd, __initdata_begin, __initdata_end, PAGE_KERNEL,
> + &vmlinux_initdata);
> map_kernel_segment(pgd, _data, _end, PAGE_KERNEL, &vmlinux_data);
>
> if (!pgd_val(*pgd_offset_raw(pgd, FIXADDR_START))) {
> --
> 2.7.4
>
prev parent reply other threads:[~2017-02-14 15:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-11 20:23 [PATCH v2 0/5] arm64: mmu: avoid writeable-executable mappings Ard Biesheuvel
2017-02-11 20:23 ` [PATCH v2 1/5] arm: kvm: move kvm_vgic_global_state out of .text section Ard Biesheuvel
2017-02-11 20:23 ` [PATCH v2 2/5] arm64: mmu: move TLB maintenance from callers to create_mapping_late() Ard Biesheuvel
2017-02-14 15:54 ` Mark Rutland
2017-02-11 20:23 ` [PATCH v2 3/5] arm64: alternatives: apply boot time fixups via the linear mapping Ard Biesheuvel
2017-02-14 15:56 ` Mark Rutland
2017-02-11 20:23 ` [PATCH v2 4/5] arm64: mmu: map .text as read-only from the outset Ard Biesheuvel
2017-02-14 15:57 ` Mark Rutland
2017-02-14 16:15 ` Ard Biesheuvel
2017-02-14 17:40 ` Mark Rutland
2017-02-14 17:49 ` Ard Biesheuvel
2017-02-14 17:54 ` Mark Rutland
2017-02-11 20:23 ` [PATCH v2 5/5] arm64: mmu: apply strict permissions to .init.text and .init.data Ard Biesheuvel
2017-02-14 15:57 ` Mark Rutland [this message]
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=20170214155727.GF23718@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