arm64: Preventing READ_IMPLIES_EXEC propagation
authorDong Bo <dongbo4@huawei.com>
Tue, 25 Apr 2017 06:11:29 +0000 (14:11 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Jul 2017 05:00:12 +0000 (07:00 +0200)
commita6b177129a76f49e77b5b42d5f74308ebb86e165
tree947f4d399e5e866b6ee9369a3fb5f625ee84d551
parent618986c4bcda58a6ec5fc3244f061a756d549548
arm64: Preventing READ_IMPLIES_EXEC propagation

commit 48f99c8ec0b25756d0283ab058826ae07d14fad7 upstream.

Like arch/arm/, we inherit the READ_IMPLIES_EXEC personality flag across
fork(). This is undesirable for a number of reasons:

  * ELF files that don't require executable stack can end up with it
    anyway

  * We end up performing un-necessary I-cache maintenance when mapping
    what should be non-executable pages

  * Restricting what is executable is generally desirable when defending
    against overflow attacks

This patch clears the personality flag when setting up the personality for
newly spwaned native tasks. Given that semi-recent AArch64 toolchains emit
a non-executable PT_GNU_STACK header, userspace applications can already
not rely on READ_IMPLIES_EXEC so shouldn't be adversely affected by this
change.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Dong Bo <dongbo4@huawei.com>
[will: added comment to compat code, rewrote commit message]
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm64/include/asm/elf.h