From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754584AbdFWOG4 (ORCPT ); Fri, 23 Jun 2017 10:06:56 -0400 Received: from terminus.zytor.com ([65.50.211.136]:53561 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754217AbdFWOGy (ORCPT ); Fri, 23 Jun 2017 10:06:54 -0400 Date: Fri, 23 Jun 2017 07:02:09 -0700 From: tip-bot for Michal Hocko Message-ID: Cc: torvalds@linux-foundation.org, mingo@kernel.org, hpa@zytor.com, jkosina@suse.cz, mhocko@suse.com, oleg@redhat.com, tglx@linutronix.de, davej@codemonkey.org.uk, peterz@infradead.org, linux-kernel@vger.kernel.org Reply-To: torvalds@linux-foundation.org, mingo@kernel.org, jkosina@suse.cz, mhocko@suse.com, hpa@zytor.com, oleg@redhat.com, tglx@linutronix.de, davej@codemonkey.org.uk, peterz@infradead.org, linux-kernel@vger.kernel.org In-Reply-To: <20170614082218.12450-1-mhocko@kernel.org> References: <20170614082218.12450-1-mhocko@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/mm] x86/mmap, ASLR: Do not treat unlimited-stack tasks as legacy mmap Git-Commit-ID: 86b110d2ae6365ce91cabd37588bc8611770421a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 86b110d2ae6365ce91cabd37588bc8611770421a Gitweb: http://git.kernel.org/tip/86b110d2ae6365ce91cabd37588bc8611770421a Author: Michal Hocko AuthorDate: Wed, 14 Jun 2017 10:22:18 +0200 Committer: Ingo Molnar CommitDate: Fri, 23 Jun 2017 11:02:01 +0200 x86/mmap, ASLR: Do not treat unlimited-stack tasks as legacy mmap Since the following commit in 2008: cc503c1b43e0 ("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: 8817210d4d96 ("[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: Michal Hocko Cc: Dave Jones Cc: Jiri Kosina Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner 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/20170614082218.12450-1-mhocko@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: Ingo Molnar --- arch/x86/mm/mmap.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c index 19ad095..797295e 100644 --- a/arch/x86/mm/mmap.c +++ b/arch/x86/mm/mmap.c @@ -74,9 +74,6 @@ static int mmap_is_legacy(void) if (current->personality & ADDR_COMPAT_LAYOUT) return 1; - if (rlimit(RLIMIT_STACK) == RLIM_INFINITY) - return 1; - return sysctl_legacy_va_layout; }