Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755910AbbKYArm (ORCPT ); Tue, 24 Nov 2015 19:47:42 -0500 Received: from mail-ig0-f173.google.com ([209.85.213.173]:37331 "EHLO mail-ig0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753419AbbKYArj (ORCPT ); Tue, 24 Nov 2015 19:47:39 -0500 MIME-Version: 1.0 In-Reply-To: <20151124164001.71844bcfb4d7a500cd25d9c6@linux-foundation.org> References: <1447888808-31571-1-git-send-email-dcashman@android.com> <1447888808-31571-2-git-send-email-dcashman@android.com> <20151124164001.71844bcfb4d7a500cd25d9c6@linux-foundation.org> Date: Tue, 24 Nov 2015 16:47:37 -0800 X-Google-Sender-Auth: _IIhsePIfPRhz3fLIZgsymDk6TA Message-ID: Subject: Re: [PATCH v3 1/4] mm: mmap: Add new /proc tunable for mmap_base ASLR. From: Kees Cook To: Andrew Morton Cc: Daniel Cashman , LKML , Russell King - ARM Linux , Ingo Molnar , "linux-arm-kernel@lists.infradead.org" , Jonathan Corbet , Don Zickus , "Eric W. Biederman" , Heinrich Schuchardt , jpoimboe@redhat.com, "Kirill A. Shutemov" , n-horiguchi@ah.jp.nec.com, Andrea Arcangeli , Mel Gorman , Thomas Gleixner , David Rientjes , Linux-MM , "linux-doc@vger.kernel.org" , Mark Salyzyn , Jeffrey Vander Stoep , Nick Kralevich , Catalin Marinas , Will Deacon , "H. Peter Anvin" , "x86@kernel.org" , Hector Marco , Borislav Petkov , Daniel Cashman Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2823 Lines: 74 On Tue, Nov 24, 2015 at 4:40 PM, Andrew Morton wrote: > On Wed, 18 Nov 2015 15:20:05 -0800 Daniel Cashman wrote: > >> --- a/kernel/sysctl.c >> +++ b/kernel/sysctl.c >> @@ -1568,6 +1568,28 @@ static struct ctl_table vm_table[] = { >> .mode = 0644, >> .proc_handler = proc_doulongvec_minmax, >> }, >> +#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS >> + { >> + .procname = "mmap_rnd_bits", >> + .data = &mmap_rnd_bits, >> + .maxlen = sizeof(mmap_rnd_bits), >> + .mode = 0644, > > Is there any harm in permitting the attacker to read these values? > > And is there any benefit in permitting non-attackers to read them? I'm on the fence. Things like kernel/randomize_va_space is 644. But since I don't see a benefit in exposing them, let's make them all 600 instead -- it's a new interface, better to keep it narrower now. > >> + .proc_handler = proc_dointvec_minmax, >> + .extra1 = &mmap_rnd_bits_min, >> + .extra2 = &mmap_rnd_bits_max, >> + }, >> +#endif >> +#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS >> + { >> + .procname = "mmap_rnd_compat_bits", >> + .data = &mmap_rnd_compat_bits, >> + .maxlen = sizeof(mmap_rnd_compat_bits), >> + .mode = 0644, >> + .proc_handler = proc_dointvec_minmax, >> + .extra1 = &mmap_rnd_compat_bits_min, >> + .extra2 = &mmap_rnd_compat_bits_max, >> + }, >> +#endif >> >> ... >> >> +#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS >> +int mmap_rnd_bits_min = CONFIG_ARCH_MMAP_RND_BITS_MIN; >> +int mmap_rnd_bits_max = CONFIG_ARCH_MMAP_RND_BITS_MAX; >> +int mmap_rnd_bits = CONFIG_ARCH_MMAP_RND_BITS; >> +#endif >> +#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS >> +int mmap_rnd_compat_bits_min = CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN; >> +int mmap_rnd_compat_bits_max = CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX; >> +int mmap_rnd_compat_bits = CONFIG_ARCH_MMAP_RND_COMPAT_BITS; > > These could be __read_mostly. > > If one believes in such things. One effect of __read_mostly is to > clump the write-often stuff into the same cachelines and I've never > been convinced that one outweighs the other... The _min and _max values should be const, actually, since they're build-time selected. The _bits could easily be __read_mostly, yeah. -Kees -- Kees Cook Chrome OS & Brillo Security -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/