Skip to content

Commit 01578e3

Browse files
oleg-nesterovKAGA-KOKO
authored andcommitted
x86/elf: Remove the unnecessary ADDR_NO_RANDOMIZE checks
The ADDR_NO_RANDOMIZE checks in stack_maxrandom_size() and randomize_stack_top() are not required. PF_RANDOMIZE is set by load_elf_binary() only if ADDR_NO_RANDOMIZE is not set, no need to re-check after that. Signed-off-by: Oleg Nesterov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Dmitry Safonov <[email protected]> Cc: [email protected] Cc: Andy Lutomirski <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
1 parent 47ac548 commit 01578e3

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

arch/x86/mm/mmap.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ unsigned long tasksize_64bit(void)
5050
static unsigned long stack_maxrandom_size(unsigned long task_size)
5151
{
5252
unsigned long max = 0;
53-
if ((current->flags & PF_RANDOMIZE) &&
54-
!(current->personality & ADDR_NO_RANDOMIZE)) {
53+
if (current->flags & PF_RANDOMIZE) {
5554
max = (-1UL) & __STACK_RND_MASK(task_size == tasksize_32bit());
5655
max <<= PAGE_SHIFT;
5756
}

fs/binfmt_elf.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,7 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
664664
{
665665
unsigned long random_variable = 0;
666666

667-
if ((current->flags & PF_RANDOMIZE) &&
668-
!(current->personality & ADDR_NO_RANDOMIZE)) {
667+
if (current->flags & PF_RANDOMIZE) {
669668
random_variable = get_random_long();
670669
random_variable &= STACK_RND_MASK;
671670
random_variable <<= PAGE_SHIFT;

0 commit comments

Comments
 (0)