Loading arch/Kconfig +7 −0 Original line number Diff line number Diff line Loading @@ -484,6 +484,13 @@ config HAVE_IRQ_EXIT_ON_IRQ_STACK This spares a stack switch and improves cache usage on softirq processing. config ARCH_HAS_ELF_RANDOMIZE bool help An architecture supports choosing randomized locations for stack, mmap, brk, and ET_DYN. Defined functions: - arch_mmap_rnd() # # ABI hall of shame # Loading arch/arm/Kconfig +1 −1 Original line number Diff line number Diff line config ARM bool default y select ARCH_BINFMT_ELF_RANDOMIZE_PIE select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_MIGHT_HAVE_PC_PARPORT Loading arch/arm/mm/mmap.c +12 −4 Original line number Diff line number Diff line Loading @@ -169,14 +169,22 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, return addr; } unsigned long arch_mmap_rnd(void) { unsigned long rnd; /* 8 bits of randomness in 20 address space bits */ rnd = (unsigned long)get_random_int() % (1 << 8); return rnd << PAGE_SHIFT; } void arch_pick_mmap_layout(struct mm_struct *mm) { unsigned long random_factor = 0UL; /* 8 bits of randomness in 20 address space bits */ if ((current->flags & PF_RANDOMIZE) && !(current->personality & ADDR_NO_RANDOMIZE)) random_factor = (get_random_int() % (1 << 8)) << PAGE_SHIFT; if (current->flags & PF_RANDOMIZE) random_factor = arch_mmap_rnd(); if (mmap_is_legacy()) { mm->mmap_base = TASK_UNMAPPED_BASE + random_factor; Loading arch/arm64/Kconfig +1 −1 Original line number Diff line number Diff line config ARM64 def_bool y select ARCH_BINFMT_ELF_RANDOMIZE_PIE select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_SG_CHAIN select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_USE_CMPXCHG_LOCKREF Loading arch/arm64/include/asm/elf.h +0 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,6 @@ typedef struct user_fpsimd_state elf_fpregset_t; * the loader. We need to make sure that it is out of the way of the program * that it will "exec", and that there is sufficient room for the brk. */ extern unsigned long randomize_et_dyn(unsigned long base); #define ELF_ET_DYN_BASE (2 * TASK_SIZE_64 / 3) /* Loading Loading
arch/Kconfig +7 −0 Original line number Diff line number Diff line Loading @@ -484,6 +484,13 @@ config HAVE_IRQ_EXIT_ON_IRQ_STACK This spares a stack switch and improves cache usage on softirq processing. config ARCH_HAS_ELF_RANDOMIZE bool help An architecture supports choosing randomized locations for stack, mmap, brk, and ET_DYN. Defined functions: - arch_mmap_rnd() # # ABI hall of shame # Loading
arch/arm/Kconfig +1 −1 Original line number Diff line number Diff line config ARM bool default y select ARCH_BINFMT_ELF_RANDOMIZE_PIE select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_MIGHT_HAVE_PC_PARPORT Loading
arch/arm/mm/mmap.c +12 −4 Original line number Diff line number Diff line Loading @@ -169,14 +169,22 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, return addr; } unsigned long arch_mmap_rnd(void) { unsigned long rnd; /* 8 bits of randomness in 20 address space bits */ rnd = (unsigned long)get_random_int() % (1 << 8); return rnd << PAGE_SHIFT; } void arch_pick_mmap_layout(struct mm_struct *mm) { unsigned long random_factor = 0UL; /* 8 bits of randomness in 20 address space bits */ if ((current->flags & PF_RANDOMIZE) && !(current->personality & ADDR_NO_RANDOMIZE)) random_factor = (get_random_int() % (1 << 8)) << PAGE_SHIFT; if (current->flags & PF_RANDOMIZE) random_factor = arch_mmap_rnd(); if (mmap_is_legacy()) { mm->mmap_base = TASK_UNMAPPED_BASE + random_factor; Loading
arch/arm64/Kconfig +1 −1 Original line number Diff line number Diff line config ARM64 def_bool y select ARCH_BINFMT_ELF_RANDOMIZE_PIE select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_SG_CHAIN select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_USE_CMPXCHG_LOCKREF Loading
arch/arm64/include/asm/elf.h +0 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,6 @@ typedef struct user_fpsimd_state elf_fpregset_t; * the loader. We need to make sure that it is out of the way of the program * that it will "exec", and that there is sufficient room for the brk. */ extern unsigned long randomize_et_dyn(unsigned long base); #define ELF_ET_DYN_BASE (2 * TASK_SIZE_64 / 3) /* Loading