From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756438AbbJ1XnP (ORCPT ); Wed, 28 Oct 2015 19:43:15 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:44163 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755978AbbJ1XnN (ORCPT ); Wed, 28 Oct 2015 19:43:13 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Daniel Cashman Cc: linux-kernel@vger.kernel.org, linux@arm.linux.org.uk, akpm@linux-foundation.org, keescook@chromium.org, mingo@kernel.org, linux-arm-kernel@lists.infradead.org, corbet@lwn.net, dzickus@redhat.com, xypron.glpk@gmx.de, jpoimboe@redhat.com, kirill.shutemov@linux.intel.com, n-horiguchi@ah.jp.nec.com, aarcange@redhat.com, mgorman@suse.de, tglx@linutronix.de, rientjes@google.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, salyzyn@android.com, jeffv@google.com, nnk@google.com, dcashman References: <1446067520-31806-1-git-send-email-dcashman@android.com> Date: Wed, 28 Oct 2015 18:34:15 -0500 In-Reply-To: <1446067520-31806-1-git-send-email-dcashman@android.com> (Daniel Cashman's message of "Wed, 28 Oct 2015 14:25:19 -0700") Message-ID: <871tcewoso.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-AID: U2FsdGVkX19A7Ep02B422g5EFBJV88z7pCqckt1uv/o= X-SA-Exim-Connect-IP: 67.3.201.231 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject * 0.0 T_TooManySym_02 5+ unique symbols in subject X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Daniel Cashman X-Spam-Relay-Country: X-Spam-Timing: total 715 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 3.6 (0.5%), b_tie_ro: 2.6 (0.4%), parse: 1.17 (0.2%), extract_message_metadata: 20 (2.8%), get_uri_detail_list: 3.5 (0.5%), tests_pri_-1000: 7 (1.0%), tests_pri_-950: 1.72 (0.2%), tests_pri_-900: 1.52 (0.2%), tests_pri_-400: 36 (5.1%), check_bayes: 34 (4.8%), b_tokenize: 14 (2.0%), b_tok_get_all: 9 (1.3%), b_comp_prob: 3.8 (0.5%), b_tok_touch_all: 4.5 (0.6%), b_finish: 0.93 (0.1%), tests_pri_0: 634 (88.7%), tests_pri_500: 4.2 (0.6%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 1/2] mm: mmap: Add new /proc tunable for mmap_base ASLR. X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Wed, 24 Sep 2014 11:00:52 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Daniel Cashman writes: > From: dcashman > > ASLR currently only uses 8 bits to generate the random offset for the > mmap base address on 32 bit architectures. This value was chosen to > prevent a poorly chosen value from dividing the address space in such > a way as to prevent large allocations. This may not be an issue on all > platforms. Allow the specification of a minimum number of bits so that > platforms desiring greater ASLR protection may determine where to place > the trade-off. This all would be much cleaner if the arm architecture code were just to register the sysctl itself. As it sits this looks like a patchset that does not meaninfully bisect, and would result in code that is hard to trace and understand. Eric > Signed-off-by: Daniel Cashman > --- > Documentation/sysctl/kernel.txt | 14 ++++++++++++++ > include/linux/mm.h | 6 ++++++ > kernel/sysctl.c | 11 +++++++++++ > 3 files changed, 31 insertions(+) > > diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt > index 6fccb69..0d4ca53 100644 > --- a/Documentation/sysctl/kernel.txt > +++ b/Documentation/sysctl/kernel.txt > @@ -41,6 +41,7 @@ show up in /proc/sys/kernel: > - kptr_restrict > - kstack_depth_to_print [ X86 only ] > - l2cr [ PPC only ] > +- mmap_rnd_bits > - modprobe ==> Documentation/debugging-modules.txt > - modules_disabled > - msg_next_id [ sysv ipc ] > @@ -391,6 +392,19 @@ This flag controls the L2 cache of G3 processor boards. If > > ============================================================== > > +mmap_rnd_bits: > + > +This value can be used to select the number of bits to use to > +determine the random offset to the base address of vma regions > +resulting from mmap allocations on architectures which support > +tuning address space randomization. This value will be bounded > +by the architecture's minimum and maximum supported values. > + > +This value can be changed after boot using the > +/proc/sys/kernel/mmap_rnd_bits tunable > + > +============================================================== > + > modules_disabled: > > A toggle value indicating if modules are allowed to be loaded > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 80001de..15b083a 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -51,6 +51,12 @@ extern int sysctl_legacy_va_layout; > #define sysctl_legacy_va_layout 0 > #endif > > +#ifdef CONFIG_ARCH_MMAP_RND_BITS > +extern int mmap_rnd_bits_min; > +extern int mmap_rnd_bits_max; > +extern int mmap_rnd_bits; > +#endif > + > #include > #include > #include > diff --git a/kernel/sysctl.c b/kernel/sysctl.c > index e69201d..37e657a 100644 > --- a/kernel/sysctl.c > +++ b/kernel/sysctl.c > @@ -1139,6 +1139,17 @@ static struct ctl_table kern_table[] = { > .proc_handler = timer_migration_handler, > }, > #endif > +#ifdef CONFIG_ARCH_MMAP_RND_BITS > + { > + .procname = "mmap_rnd_bits", > + .data = &mmap_rnd_bits, > + .maxlen = sizeof(mmap_rnd_bits), > + .mode = 0644, > + .proc_handler = proc_dointvec_minmax, > + .extra1 = &mmap_rnd_bits_min, > + .extra2 = &mmap_rnd_bits_max, > + }, > +#endif > { } > };