aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2015-04-14 18:48:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-14 19:49:05 -0400
commitc6f5b001e65cdac592b65a08c5d2dd179cfba568 (patch)
tree3039e744e13eac169969882aed3226a8f6ce6186 /arch/s390
parent2b68f6caeac271620cd2f9362aeaed360e317df0 (diff)
s390: redefine randomize_et_dyn for ELF_ET_DYN_BASE
In preparation for moving ET_DYN randomization into the ELF loader (which requires a static ELF_ET_DYN_BASE), this redefines s390's existing ET_DYN randomization in a call to arch_mmap_rnd(). This refactoring results in the same ET_DYN randomization on s390. Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Reviewed-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/s390')
-rw-r--r--arch/s390/include/asm/elf.h8
-rw-r--r--arch/s390/mm/mmap.c11
2 files changed, 7 insertions, 12 deletions
diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
index c9c875d9ed31..f8db4781a4c2 100644
--- a/arch/s390/include/asm/elf.h
+++ b/arch/s390/include/asm/elf.h
@@ -161,10 +161,12 @@ extern unsigned int vdso_enabled;
161/* This is the location that an ET_DYN program is loaded if exec'ed. Typical 161/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
162 use of this is to invoke "./ld.so someprog" to test out a new version of 162 use of this is to invoke "./ld.so someprog" to test out a new version of
163 the loader. We need to make sure that it is out of the way of the program 163 the loader. We need to make sure that it is out of the way of the program
164 that it will "exec", and that there is sufficient room for the brk. */ 164 that it will "exec", and that there is sufficient room for the brk. 64-bit
165 165 tasks are aligned to 4GB. */
166extern unsigned long randomize_et_dyn(void); 166extern unsigned long randomize_et_dyn(void);
167#define ELF_ET_DYN_BASE randomize_et_dyn() 167#define ELF_ET_DYN_BASE (randomize_et_dyn() + (is_32bit_task() ? \
168 (STACK_TOP / 3 * 2) : \
169 (STACK_TOP / 3 * 2) & ~((1UL << 32) - 1)))
168 170
169/* This yields a mask that user programs can use to figure out what 171/* This yields a mask that user programs can use to figure out what
170 instruction set this CPU supports. */ 172 instruction set this CPU supports. */
diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
index a94504d99c47..8c11536f972d 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -179,17 +179,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
179 179
180unsigned long randomize_et_dyn(void) 180unsigned long randomize_et_dyn(void)
181{ 181{
182 unsigned long base;
183
184 base = STACK_TOP / 3 * 2;
185 if (!is_32bit_task())
186 /* Align to 4GB */
187 base &= ~((1UL << 32) - 1);
188
189 if (current->flags & PF_RANDOMIZE) 182 if (current->flags & PF_RANDOMIZE)
190 base += arch_mmap_rnd(); 183 return arch_mmap_rnd();
191 184
192 return base; 185 return 0UL;
193} 186}
194 187
195#ifndef CONFIG_64BIT 188#ifndef CONFIG_64BIT