Skip to content

Commit d68c9d6

Browse files
fbuihuuLinus Torvalds
authored andcommitted
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 <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Arjan van de Ven <[email protected]> Cc: Ralf Baechle <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 96358de commit d68c9d6

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

fs/binfmt_elf.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
150150
struct task_struct *tsk = current;
151151
struct vm_area_struct *vma;
152152

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+
153161
/*
154162
* If this architecture has a platform capability string, copy it
155163
* to userspace. In some cases (Sparc), this info is impossible
@@ -160,14 +168,6 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
160168
if (k_platform) {
161169
size_t len = strlen(k_platform) + 1;
162170

163-
/*
164-
* In some cases (e.g. Hyper-Threading), we want to avoid L1
165-
* evictions by the processes running on the same package. One
166-
* thing we can do is to shuffle the initial stack for them.
167-
*/
168-
169-
p = arch_align_stack(p);
170-
171171
u_platform = (elf_addr_t __user *)STACK_ALLOC(p, len);
172172
if (__copy_to_user(u_platform, k_platform, len))
173173
return -EFAULT;

0 commit comments

Comments
 (0)