Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Break ELF_PLATFORM and stack pointer randomization dependency

Currently arch_align_stack() is used by fs/binfmt_elf.c to randomize
stack pointer inside a page. But this happens only if ELF_PLATFORM
symbol is defined.

ELF_PLATFORM is normally set if the architecture wants ld.so to load
implementation specific libraries for optimization. And currently a
lot of architectures just yield this symbol to NULL.

This is the case for MIPS architecture where ELF_PLATFORM is NULL but
arch_align_stack() has been redefined to do stack inside page
randomization. So in this case no randomization is actually done.

This patch breaks this dependency which seems to be useless and allows
platforms such MIPS to do the randomization.

Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Arjan van de Ven <arjan@infradead.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Franck Bui-Huu and committed by
Linus Torvalds
d68c9d6a 96358de6

+8 -8
+8 -8
fs/binfmt_elf.c
··· 151 151 struct vm_area_struct *vma; 152 152 153 153 /* 154 + * In some cases (e.g. Hyper-Threading), we want to avoid L1 155 + * evictions by the processes running on the same package. One 156 + * thing we can do is to shuffle the initial stack for them. 157 + */ 158 + 159 + p = arch_align_stack(p); 160 + 161 + /* 154 162 * If this architecture has a platform capability string, copy it 155 163 * to userspace. In some cases (Sparc), this info is impossible 156 164 * for userspace to get any other way, in others (i386) it is ··· 167 159 u_platform = NULL; 168 160 if (k_platform) { 169 161 size_t len = strlen(k_platform) + 1; 170 - 171 - /* 172 - * In some cases (e.g. Hyper-Threading), we want to avoid L1 173 - * evictions by the processes running on the same package. One 174 - * thing we can do is to shuffle the initial stack for them. 175 - */ 176 - 177 - p = arch_align_stack(p); 178 162 179 163 u_platform = (elf_addr_t __user *)STACK_ALLOC(p, len); 180 164 if (__copy_to_user(u_platform, k_platform, len))