Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92980405 authored by Arun Chandran's avatar Arun Chandran Committed by Catalin Marinas
Browse files

arm64: ASLR: Don't randomise text when randomise_va_space == 0



When user asks to turn off ASLR by writing "0" to
/proc/sys/kernel/randomize_va_space there should not be
any randomization to mmap base, stack, VDSO, libs, text and heap

Currently arm64 violates this behavior by randomising text.
Fix this by defining a constant ELF_ET_DYN_BASE. The randomisation of
mm->mmap_base is done by setup_new_exec -> arch_pick_mmap_layout ->
mmap_base -> mmap_rnd.

Signed-off-by: default avatarArun Chandran <achandran@mvista.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent e2b6b35e
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
config ARM64
config ARM64
	def_bool y
	def_bool y
	select ARCH_BINFMT_ELF_RANDOMIZE_PIE
	select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
	select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
	select ARCH_HAS_SG_CHAIN
	select ARCH_HAS_SG_CHAIN
	select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
	select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
+2 −2
Original line number Original line Diff line number Diff line
@@ -126,7 +126,7 @@ typedef struct user_fpsimd_state elf_fpregset_t;
 * that it will "exec", and that there is sufficient room for the brk.
 * that it will "exec", and that there is sufficient room for the brk.
 */
 */
extern unsigned long randomize_et_dyn(unsigned long base);
extern unsigned long randomize_et_dyn(unsigned long base);
#define ELF_ET_DYN_BASE	(randomize_et_dyn(2 * TASK_SIZE_64 / 3))
#define ELF_ET_DYN_BASE	(2 * TASK_SIZE_64 / 3)


/*
/*
 * When the program starts, a1 contains a pointer to a function to be
 * When the program starts, a1 contains a pointer to a function to be
@@ -169,7 +169,7 @@ extern unsigned long arch_randomize_brk(struct mm_struct *mm);
#define COMPAT_ELF_PLATFORM		("v8l")
#define COMPAT_ELF_PLATFORM		("v8l")
#endif
#endif


#define COMPAT_ELF_ET_DYN_BASE		(randomize_et_dyn(2 * TASK_SIZE_32 / 3))
#define COMPAT_ELF_ET_DYN_BASE		(2 * TASK_SIZE_32 / 3)


/* AArch32 registers. */
/* AArch32 registers. */
#define COMPAT_ELF_NGREG		18
#define COMPAT_ELF_NGREG		18
+0 −5
Original line number Original line Diff line number Diff line
@@ -378,8 +378,3 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
{
{
	return randomize_base(mm->brk);
	return randomize_base(mm->brk);
}
}

unsigned long randomize_et_dyn(unsigned long base)
{
	return randomize_base(base);
}