Skip to content

Commit 400eeff

Browse files
philipderrinRussell King
authored andcommitted
ARM: 8722/1: mm: make STRICT_KERNEL_RWX effective for LPAE
Currently, for ARM kernels with CONFIG_ARM_LPAE and CONFIG_STRICT_KERNEL_RWX enabled, the 2MiB pages mapping the kernel code and rodata are writable. They are marked read-only in a software bit (L_PMD_SECT_RDONLY) but the hardware read-only bit is not set (PMD_SECT_AP2). For user mappings, the logic that propagates the software bit to the hardware bit is in set_pmd_at(); but for the kernel, section_update() writes the PMDs directly, skipping this logic. The fix is to set PMD_SECT_AP2 for read-only sections in section_update(), at the same time as L_PMD_SECT_RDONLY. Fixes: 1e34792 ("ARM: 8275/1: mm: fix PMD_SECT_RDONLY undeclared compile error") Signed-off-by: Philip Derrin <philip@cog.systems> Reported-by: Neil Dick <neil@cog.systems> Tested-by: Neil Dick <neil@cog.systems> Tested-by: Laura Abbott <labbott@redhat.com> Reviewed-by: Kees Cook <keescook@chromium.org> Cc: stable@vger.kernel.org Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
1 parent 3b0c0c9 commit 400eeff

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/arm/mm/init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,8 @@ static struct section_perm ro_perms[] = {
639639
.start = (unsigned long)_stext,
640640
.end = (unsigned long)__init_begin,
641641
#ifdef CONFIG_ARM_LPAE
642-
.mask = ~L_PMD_SECT_RDONLY,
643-
.prot = L_PMD_SECT_RDONLY,
642+
.mask = ~(L_PMD_SECT_RDONLY | PMD_SECT_AP2),
643+
.prot = L_PMD_SECT_RDONLY | PMD_SECT_AP2,
644644
#else
645645
.mask = ~(PMD_SECT_APX | PMD_SECT_AP_WRITE),
646646
.prot = PMD_SECT_APX | PMD_SECT_AP_WRITE,

0 commit comments

Comments
 (0)