Skip to content

Commit 9298040

Browse files
arun-chandranctmarinas
authored andcommitted
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: Arun Chandran <[email protected]> Signed-off-by: Catalin Marinas <[email protected]>
1 parent e2b6b35 commit 9298040

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

arch/arm64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
config ARM64
22
def_bool y
3+
select ARCH_BINFMT_ELF_RANDOMIZE_PIE
34
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
45
select ARCH_HAS_SG_CHAIN
56
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST

arch/arm64/include/asm/elf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ typedef struct user_fpsimd_state elf_fpregset_t;
126126
* that it will "exec", and that there is sufficient room for the brk.
127127
*/
128128
extern unsigned long randomize_et_dyn(unsigned long base);
129-
#define ELF_ET_DYN_BASE (randomize_et_dyn(2 * TASK_SIZE_64 / 3))
129+
#define ELF_ET_DYN_BASE (2 * TASK_SIZE_64 / 3)
130130

131131
/*
132132
* 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);
169169
#define COMPAT_ELF_PLATFORM ("v8l")
170170
#endif
171171

172-
#define COMPAT_ELF_ET_DYN_BASE (randomize_et_dyn(2 * TASK_SIZE_32 / 3))
172+
#define COMPAT_ELF_ET_DYN_BASE (2 * TASK_SIZE_32 / 3)
173173

174174
/* AArch32 registers. */
175175
#define COMPAT_ELF_NGREG 18

arch/arm64/kernel/process.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,3 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
378378
{
379379
return randomize_base(mm->brk);
380380
}
381-
382-
unsigned long randomize_et_dyn(unsigned long base)
383-
{
384-
return randomize_base(base);
385-
}

0 commit comments

Comments
 (0)