• Michal Hocko's avatar
    x86/mmap, ASLR: Do not treat unlimited-stack tasks as legacy mmap · 4a06370b
    Michal Hocko authored
    Since the following commit in 2008:
    
      cc503c1b ("x86: PIE executable randomization")
    
    We added a heuristics to treat applications with RLIMIT_STACK configured
    to unlimited as legacy. This means:
    
     a) set the mmap_base to 1/3 of address space + randomization and
     b) mmap from bottom to top.
    
    This makes some sense as it allows the stack to grow really large. On the
    other hand it reduces the address space usable for default mmaps
    (without address hint) quite a lot.
    
    We have received a bug report that SAP HANA workload has hit into this
    limitation.
    
    We could argue that the user just got what he asked for when setting
    up the unlimited stack but to be realistic growing stack up to 1/6
    TASK_SIZE (allowed by mmap_base) is pretty much unimited in the real
    life. This would give mmap 20TB of additional address space which is
    quite nice. Especially when it is much more likely to use that address
    space than the reserved stack.
    
    Digging into the history the original implementation of the randomization:
    
      8817210d ("[PATCH] x86_64: Flexmap for 32bit and randomized mappings for 64bit")
    
    didn't have this restriction.
    
    So let's try and remove this assumption - hopefully nothing breaks.
    Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
    Acked-by: default avatarJiri Kosina <jkosina@suse.cz>
    Acked-by: default avatarOleg Nesterov <oleg@redhat.com>
    Cc: Dave Jones <davej@codemonkey.org.uk>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: akpm@linux-foundation.org
    Cc: hughd@google.com
    Cc: linux-mm@kvack.org
    Cc: will.deacon@arm.com
    Link: http://lkml.kernel.org/r/tip-86b110d2ae6365ce91cabd37588bc8611770421a@git.kernel.org
    [ So I've applied this to tip:x86/mm with a wider Cc: list - if anyone objects to this change please holler. ]
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    4a06370b
mmap.c 4.46 KB