]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
powerpc/32s: Don't warn when mapping RO data ROX.
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Tue, 19 May 2020 05:48:56 +0000 (05:48 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Jun 2020 15:50:34 +0000 (17:50 +0200)
[ Upstream commit 4b19f96a81bceaf0bcf44d79c0855c61158065ec ]

Mapping RO data as ROX is not an issue since that data
cannot be modified to introduce an exploit.

PPC64 accepts to have RO data mapped ROX, as a trade off
between kernel size and strictness of protection.

On PPC32, kernel size is even more critical as amount of
memory is usually small.

Depending on the number of available IBATs, the last IBATs
might overflow the end of text. Only warn if it crosses
the end of RO data.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/6499f8eeb2a36330e5c9fc1cee9a79374875bd54.1589866984.git.christophe.leroy@csgroup.eu
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/powerpc/mm/book3s32/mmu.c

index 84d5fab94f8f82795cedaa29c2e1c28041ab6e17..1424a120710e4b97a80984421afbed09aca7b2fe 100644 (file)
@@ -187,6 +187,7 @@ void mmu_mark_initmem_nx(void)
        int i;
        unsigned long base = (unsigned long)_stext - PAGE_OFFSET;
        unsigned long top = (unsigned long)_etext - PAGE_OFFSET;
+       unsigned long border = (unsigned long)__init_begin - PAGE_OFFSET;
        unsigned long size;
 
        if (IS_ENABLED(CONFIG_PPC_BOOK3S_601))
@@ -201,9 +202,10 @@ void mmu_mark_initmem_nx(void)
                size = block_size(base, top);
                size = max(size, 128UL << 10);
                if ((top - base) > size) {
-                       if (strict_kernel_rwx_enabled())
-                               pr_warn("Kernel _etext not properly aligned\n");
                        size <<= 1;
+                       if (strict_kernel_rwx_enabled() && base + size > border)
+                               pr_warn("Some RW data is getting mapped X. "
+                                       "Adjust CONFIG_DATA_SHIFT to avoid that.\n");
                }
                setibat(i++, PAGE_OFFSET + base, base, size, PAGE_KERNEL_TEXT);
                base += size;