aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/binfmt_elf.c2
-rw-r--r--init/Kconfig12
-rw-r--r--mm/memory.c13
3 files changed, 25 insertions, 2 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 4628c42ca892..111771d38e6e 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1077,7 +1077,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
1077 current->mm->start_stack = bprm->p; 1077 current->mm->start_stack = bprm->p;
1078 1078
1079#ifdef arch_randomize_brk 1079#ifdef arch_randomize_brk
1080 if (current->flags & PF_RANDOMIZE) 1080 if ((current->flags & PF_RANDOMIZE) && (randomize_va_space > 1))
1081 current->mm->brk = current->mm->start_brk = 1081 current->mm->brk = current->mm->start_brk =
1082 arch_randomize_brk(current->mm); 1082 arch_randomize_brk(current->mm);
1083#endif 1083#endif
diff --git a/init/Kconfig b/init/Kconfig
index 87f50df58893..92b23e256614 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -541,6 +541,18 @@ config ELF_CORE
541 help 541 help
542 Enable support for generating core dumps. Disabling saves about 4k. 542 Enable support for generating core dumps. Disabling saves about 4k.
543 543
544config COMPAT_BRK
545 bool "Disable heap randomization"
546 default y
547 help
548 Randomizing heap placement makes heap exploits harder, but it
549 also breaks ancient binaries (including anything libc5 based).
550 This option changes the bootup default to heap randomization
551 disabled, and can be overriden runtime by setting
552 /proc/sys/kernel/randomize_va_space to 2.
553
554 On non-ancient distros (post-2000 ones) Y is usually a safe choice.
555
544config BASE_FULL 556config BASE_FULL
545 default y 557 default y
546 bool "Enable full-sized data structures for core" if EMBEDDED 558 bool "Enable full-sized data structures for core" if EMBEDDED
diff --git a/mm/memory.c b/mm/memory.c
index 7bb70728bb52..9d073fa0a2d0 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -82,7 +82,18 @@ void * high_memory;
82EXPORT_SYMBOL(num_physpages); 82EXPORT_SYMBOL(num_physpages);
83EXPORT_SYMBOL(high_memory); 83EXPORT_SYMBOL(high_memory);
84 84
85int randomize_va_space __read_mostly = 1; 85/*
86 * Randomize the address space (stacks, mmaps, brk, etc.).
87 *
88 * ( When CONFIG_COMPAT_BRK=y we exclude brk from randomization,
89 * as ancient (libc5 based) binaries can segfault. )
90 */
91int randomize_va_space __read_mostly =
92#ifdef CONFIG_COMPAT_BRK
93 1;
94#else
95 2;
96#endif
86 97
87static int __init disable_randmaps(char *s) 98static int __init disable_randmaps(char *s)
88{ 99{