Skip to content

Commit df54d6f

Browse files
Sin42torvalds
authored andcommitted
x86 get_unmapped_area(): use proper mmap base for bottom-up direction
When the stack is set to unlimited, the bottomup direction is used for mmap-ings but the mmap_base is not used and thus effectively renders ASLR for mmapings along with PIE useless. Cc: Michel Lespinasse <[email protected]> Cc: Oleg Nesterov <[email protected]> Reviewed-by: Rik van Riel <[email protected]> Acked-by: Ingo Molnar <[email protected]> Cc: Adrian Sendroiu <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent c7dd339 commit df54d6f

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

arch/x86/kernel/sys_x86_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
101101
*begin = new_begin;
102102
}
103103
} else {
104-
*begin = TASK_UNMAPPED_BASE;
104+
*begin = mmap_legacy_base();
105105
*end = TASK_SIZE;
106106
}
107107
}

arch/x86/mm/mmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static unsigned long mmap_base(void)
9898
* Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
9999
* does, but not when emulating X86_32
100100
*/
101-
static unsigned long mmap_legacy_base(void)
101+
unsigned long mmap_legacy_base(void)
102102
{
103103
if (mmap_is_ia32())
104104
return TASK_UNMAPPED_BASE;

include/linux/sched.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ struct nsproxy;
314314
struct user_namespace;
315315

316316
#ifdef CONFIG_MMU
317+
extern unsigned long mmap_legacy_base(void);
317318
extern void arch_pick_mmap_layout(struct mm_struct *mm);
318319
extern unsigned long
319320
arch_get_unmapped_area(struct file *, unsigned long, unsigned long,

0 commit comments

Comments
 (0)