arm64: mm: use XN table mapping attributes for the linear region
authorArd Biesheuvel <ardb@kernel.org>
Wed, 10 Mar 2021 10:49:41 +0000 (11:49 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 19 Mar 2021 18:50:45 +0000 (18:50 +0000)
commit87143f404f338dbf0b51374ea48ab05e598af564
tree3909d7a6a9afb16d331eb60ebd16314b6e777dcc
parentc1fd78a77704318de34ba4b780cd99a5ef96d162
arm64: mm: use XN table mapping attributes for the linear region

The way the arm64 kernel virtual address space is constructed guarantees
that swapper PGD entries are never shared between the linear region on
the one hand, and the vmalloc region on the other, which is where all
kernel text, module text and BPF text mappings reside.

This means that mappings in the linear region (which never require
executable permissions) never share any table entries at any level with
mappings that do require executable permissions, and so we can set the
table-level PXN attributes for all table entries that are created while
setting up mappings in the linear region. Since swapper's PGD level page
table is mapped r/o itself, this adds another layer of robustness to the
way the kernel manages its own page tables. While at it, set the UXN
attribute as well for all kernel mappings created at boot.

Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Link: https://lore.kernel.org/r/20210310104942.174584-3-ardb@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/pgtable-hwdef.h
arch/arm64/mm/mmu.c