From patchwork Tue Dec 1 00:18:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 7731241 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 986179F387 for ; Tue, 1 Dec 2015 00:20:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C24F320660 for ; Tue, 1 Dec 2015 00:20:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B6E74205E9 for ; Tue, 1 Dec 2015 00:20:43 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a3YeS-0007Cr-KG; Tue, 01 Dec 2015 00:18:36 +0000 Received: from mail.linuxfoundation.org ([140.211.169.12]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a3YeP-0007BB-K9 for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2015 00:18:34 +0000 Received: from akpm3.mtv.corp.google.com (unknown [216.239.45.65]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D893586; Tue, 1 Dec 2015 00:18:11 +0000 (UTC) Date: Mon, 30 Nov 2015 16:18:11 -0800 From: Andrew Morton To: Kees Cook Subject: Re: [PATCH v4 1/4] mm: mmap: Add new /proc tunable for mmap_base ASLR. Message-Id: <20151130161811.592c205d8dc7b00f44066a37@linux-foundation.org> In-Reply-To: References: <1448578785-17656-1-git-send-email-dcashman@android.com> <1448578785-17656-2-git-send-email-dcashman@android.com> <20151130155412.b1a087f4f6f4d4180ab4472d@linux-foundation.org> <20151130160118.e43a2e53a59e347a95a94d5c@linux-foundation.org> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151130_161833_732764_0FF707BB X-CRM114-Status: GOOD ( 16.54 ) X-Spam-Score: -4.2 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Cashman , "linux-doc@vger.kernel.org" , Catalin Marinas , Will Deacon , Linux-MM , "H. Peter Anvin" , Ingo Molnar , Andrea Arcangeli , Russell King - ARM Linux , Jonathan Corbet , Heinrich Schuchardt , "x86@kernel.org" , Hector Marco , Mel Gorman , David Rientjes , Borislav Petkov , Nick Kralevich , Don Zickus , Daniel Cashman , jpoimboe@redhat.com, Thomas Gleixner , "linux-arm-kernel@lists.infradead.org" , LKML , Mark Salyzyn , "Eric W. Biederman" , Jeffrey Vander Stoep , n-horiguchi@ah.jp.nec.com, "Kirill A. Shutemov" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, 30 Nov 2015 16:04:36 -0800 Kees Cook wrote: > >> > +#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS > >> > + { > >> > + .procname = "mmap_rnd_bits", > >> > + .data = &mmap_rnd_bits, > >> > + .maxlen = sizeof(mmap_rnd_bits), > >> > + .mode = 0600, > >> > + .proc_handler = proc_dointvec_minmax, > >> > + .extra1 = (void *) &mmap_rnd_bits_min, > >> > + .extra2 = (void *) &mmap_rnd_bits_max, > >> > >> hm, why the typecasts? They're unneeded and are omitted everywhere(?) > >> else in kernel/sysctl.c. > > > > Oh. Casting away constness. > > > > What's the thinking here? They can change at any time so they aren't > > const so we shouldn't declare them to be const? > > The _min and _max values shouldn't be changing: they're decided based > on the various CONFIG options that calculate the valid min/maxes. Only > mmap_rnd_bits itself should be changing. hmpf. From: Andrew Morton Subject: include/linux/sysctl.h: make ctl_table.extra1/2 const Nothing should be altering these values. Declare the pointed-to values to be const so we can actually use const values. Cc: Kees Cook Cc: Daniel Cashman Signed-off-by: Andrew Morton --- include/linux/sysctl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff -puN kernel/sysctl.c~a kernel/sysctl.c diff -puN include/linux/sysctl.h~a include/linux/sysctl.h --- a/include/linux/sysctl.h~a +++ a/include/linux/sysctl.h @@ -111,8 +111,8 @@ struct ctl_table struct ctl_table *child; /* Deprecated */ proc_handler *proc_handler; /* Callback for text formatting */ struct ctl_table_poll *poll; - void *extra1; - void *extra2; + const void *extra1; + const void *extra2; }; struct ctl_node {