diff options
author | dcashman <dcashman@google.com> | 2015-12-29 15:28:13 -0800 |
---|---|---|
committer | Kees Cook <keescook@google.com> | 2016-03-24 15:32:03 -0700 |
commit | 08456f54219660d0e84039e07af22a72304f19fe (patch) | |
tree | 566e11bf78633d3a996a62d3c502e44dcda7c457 | |
parent | 96d089f37baee5083d894e1ca8c8d669adfd67b4 (diff) | |
download | edison-v3.10-08456f54219660d0e84039e07af22a72304f19fe.tar.gz |
BACKPORT: FROMLIST: arm64: mm: support ARCH_MMAP_RND_BITS.
(cherry picked from commit https://lkml.org/lkml/2015/12/21/340)
arm64: arch_mmap_rnd() uses STACK_RND_MASK to generate the
random offset for the mmap base address. This value represents a
compromise between increased ASLR effectiveness and avoiding
address-space fragmentation. Replace it with a Kconfig option, which
is sensibly bounded, so that platform developers may choose where to
place this compromise. Keep default values as new minimums.
Signed-off-by: Daniel Cashman <dcashman@android.com>
Signed-off-by: Daniel Cashman <dcashman@google.com>
Bug: 27796957
Patchset: ASLR sysctl
Change-Id: I2bce64c83f21c0c358e743d0d04239c805cca3f1
Signed-off-by: Kees Cook <keescook@google.com>
-rw-r--r-- | arch/arm64/Kconfig | 2 | ||||
-rw-r--r-- | arch/arm64/mm/mmap.c | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 6c41dd1b75d..a568e4dee6c 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -22,6 +22,8 @@ config ARM64 select HARDIRQS_SW_RESEND select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_SECCOMP_FILTER + select HAVE_ARCH_MMAP_RND_BITS + select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT select HAVE_ARCH_TRACEHOOK select HAVE_DEBUG_BUGVERBOSE select HAVE_DEBUG_KMEMLEAK diff --git a/arch/arm64/mm/mmap.c b/arch/arm64/mm/mmap.c index 8aaf073ee07..8af07b65eec 100644 --- a/arch/arm64/mm/mmap.c +++ b/arch/arm64/mm/mmap.c @@ -51,9 +51,14 @@ static unsigned long mmap_rnd(void) { unsigned long rnd = 0; - if (current->flags & PF_RANDOMIZE) - rnd = (long)get_random_int() & STACK_RND_MASK; - + if (current->flags & PF_RANDOMIZE) { +#ifdef CONFIG_COMPAT + if (test_thread_flag(TIF_32BIT)) + rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_compat_bits) - 1); + else +#endif + rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_bits) - 1); + } return rnd << PAGE_SHIFT; } |