Skip to content

Commit

Permalink
arm64, mm: make randomization selected by generic topdown mmap layout
Browse files Browse the repository at this point in the history
This commits selects ARCH_HAS_ELF_RANDOMIZE when an arch uses the generic
topdown mmap layout functions so that this security feature is on by
default.

Note that this commit also removes the possibility for arm64 to have elf
randomization and no MMU: without MMU, the security added by randomization
is worth nothing.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Alexandre Ghiti <[email protected]>
Acked-by: Catalin Marinas <[email protected]>
Acked-by: Kees Cook <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Luis Chamberlain <[email protected]>
Cc: Albert Ou <[email protected]>
Cc: Alexander Viro <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: James Hogan <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: Paul Burton <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Russell King <[email protected]>
Cc: Will Deacon <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
AlexGhiti authored and torvalds committed Sep 24, 2019
1 parent 67f3977 commit e7142bf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ config HAVE_ARCH_COMPAT_MMAP_BASES
config ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
bool
depends on MMU
select ARCH_HAS_ELF_RANDOMIZE

config HAVE_COPY_THREAD_TLS
bool
Expand Down
1 change: 0 additions & 1 deletion arch/arm64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ config ARM64
select ARCH_HAS_DMA_COHERENT_TO_PFN
select ARCH_HAS_DMA_PREP_COHERENT
select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
select ARCH_HAS_ELF_RANDOMIZE
select ARCH_HAS_FAST_MULTIPLIER
select ARCH_HAS_FORTIFY_SOURCE
select ARCH_HAS_GCOV_PROFILE_ALL
Expand Down
8 changes: 0 additions & 8 deletions arch/arm64/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,14 +557,6 @@ unsigned long arch_align_stack(unsigned long sp)
return sp & ~0xf;
}

unsigned long arch_randomize_brk(struct mm_struct *mm)
{
if (is_compat_task())
return randomize_page(mm->brk, SZ_32M);
else
return randomize_page(mm->brk, SZ_1G);
}

/*
* Called from setup_new_exec() after (COMPAT_)SET_PERSONALITY.
*/
Expand Down
11 changes: 9 additions & 2 deletions mm/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,15 @@ unsigned long randomize_stack_top(unsigned long stack_top)
}

#ifdef CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
#ifdef CONFIG_ARCH_HAS_ELF_RANDOMIZE
unsigned long arch_randomize_brk(struct mm_struct *mm)
{
/* Is the current task 32bit ? */
if (!IS_ENABLED(CONFIG_64BIT) || is_compat_task())
return randomize_page(mm->brk, SZ_32M);

return randomize_page(mm->brk, SZ_1G);
}

unsigned long arch_mmap_rnd(void)
{
unsigned long rnd;
Expand All @@ -335,7 +343,6 @@ unsigned long arch_mmap_rnd(void)

return rnd << PAGE_SHIFT;
}
#endif /* CONFIG_ARCH_HAS_ELF_RANDOMIZE */

static int mmap_is_legacy(struct rlimit *rlim_stack)
{
Expand Down

0 comments on commit e7142bf

Please sign in to comment.