]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
powerpc/mm: Mark __init memory no-execute when STRICT_KERNEL_RWX=y
authorMichael Ellerman <mpe@ellerman.id.au>
Fri, 14 Jul 2017 06:51:23 +0000 (16:51 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 18 Jul 2017 09:54:24 +0000 (19:54 +1000)
commit029d9252b116fa52a95150819e62af1f6e420fe5
tree6f7832ca67de31a117dbb1b3346bfae3ec1a348e
parentfa7f9189e017213bad63b93a76de5c715cd62a96
powerpc/mm: Mark __init memory no-execute when STRICT_KERNEL_RWX=y

Currently even with STRICT_KERNEL_RWX we leave the __init text marked
executable after init, which is bad.

Add a hook to mark it NX (no-execute) before we free it, and implement
it for radix and hash.

Note that we use __init_end as the end address, not _einittext,
because overlaps_kernel_text() uses __init_end, because there are
additional executable sections other than .init.text between
__init_begin and __init_end.

Tested on radix and hash with:

  0:mon> p $__init_begin
  *** 400 exception occurred

Fixes: 1e0fc9d1eb2b ("powerpc/Kconfig: Enable STRICT_KERNEL_RWX for some configs")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/book3s/64/hash.h
arch/powerpc/include/asm/book3s/64/pgtable.h
arch/powerpc/include/asm/book3s/64/radix.h
arch/powerpc/include/asm/pgtable.h
arch/powerpc/mm/mem.c
arch/powerpc/mm/pgtable-hash64.c
arch/powerpc/mm/pgtable-radix.c
arch/powerpc/mm/pgtable_64.c