From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932265AbcF2TIb (ORCPT ); Wed, 29 Jun 2016 15:08:31 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35165 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751996AbcF2TI2 (ORCPT ); Wed, 29 Jun 2016 15:08:28 -0400 Date: Wed, 29 Jun 2016 21:03:19 +0200 From: Emese Revfy To: Rasmus Villemoes Cc: kernel-hardening@lists.openwall.com, pageexec@freemail.hu, spender@grsecurity.net, mmarek@suse.com, keescook@chromium.org, linux-kernel@vger.kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, minipli@ld-linux.so, linux@armlinux.org.uk, catalin.marinas@arm.com, david.brown@linaro.org, benh@kernel.crashing.org, tglx@linutronix.de, akpm@linux-foundation.org, jlayton@poochiereds.net, arnd@arndb.de Subject: Re: [PATCH v1 1/2] Add the initify gcc plugin Message-Id: <20160629210319.07dc960dc26fd109a636b1ff@gmail.com> In-Reply-To: <87vb0tgh1n.fsf@rasmusvillemoes.dk> References: <20160628133407.10c2ea1ecd194e8085e84c5a@gmail.com> <20160628133520.5baf644afca97c464b9cdb17@gmail.com> <87vb0tgh1n.fsf@rasmusvillemoes.dk> X-Mailer: Sylpheed 3.5.0 (GTK+ 2.24.30; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 28 Jun 2016 23:05:56 +0200 Rasmus Villemoes wrote: > On Tue, Jun 28 2016, Emese Revfy wrote: > > > The kernel already has a mechanism to free up code and data memory that > > is only used during kernel or module initialization. > > This plugin will teach the compiler to find more such code and data that > > can be freed after initialization. > > It has two passes. The first one tries to find all functions that > > can be become __init/__exit. The second one moves string constants > > (local variables and function string arguments marked by > > the nocapture attribute) only referenced in __init/__exit functions > > to the __initconst/__exitconst sections. > > It reduces memory usage. This plugin can be useful for embedded systems. > > May I suggest, as a followup patch, a debug option/plugin parameter to > put the strings in a section which will not be reaped after init, but > just marked inaccessible, with graceful handling of bad accesses (print > a big fat warning, make the page(s) readable, continue)? I think even better would be to verify the whole init section. Unfortunately, I won't implement it anytime soon because my project ends this week. -- Emese From mboxrd@z Thu Jan 1 00:00:00 1970 Reply-To: kernel-hardening@lists.openwall.com Date: Wed, 29 Jun 2016 21:03:19 +0200 From: Emese Revfy Message-Id: <20160629210319.07dc960dc26fd109a636b1ff@gmail.com> In-Reply-To: <87vb0tgh1n.fsf@rasmusvillemoes.dk> References: <20160628133407.10c2ea1ecd194e8085e84c5a@gmail.com> <20160628133520.5baf644afca97c464b9cdb17@gmail.com> <87vb0tgh1n.fsf@rasmusvillemoes.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: [kernel-hardening] Re: [PATCH v1 1/2] Add the initify gcc plugin To: Rasmus Villemoes Cc: kernel-hardening@lists.openwall.com, pageexec@freemail.hu, spender@grsecurity.net, mmarek@suse.com, keescook@chromium.org, linux-kernel@vger.kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, minipli@ld-linux.so, linux@armlinux.org.uk, catalin.marinas@arm.com, david.brown@linaro.org, benh@kernel.crashing.org, tglx@linutronix.de, akpm@linux-foundation.org, jlayton@poochiereds.net, arnd@arndb.de List-ID: On Tue, 28 Jun 2016 23:05:56 +0200 Rasmus Villemoes wrote: > On Tue, Jun 28 2016, Emese Revfy wrote: > > > The kernel already has a mechanism to free up code and data memory that > > is only used during kernel or module initialization. > > This plugin will teach the compiler to find more such code and data that > > can be freed after initialization. > > It has two passes. The first one tries to find all functions that > > can be become __init/__exit. The second one moves string constants > > (local variables and function string arguments marked by > > the nocapture attribute) only referenced in __init/__exit functions > > to the __initconst/__exitconst sections. > > It reduces memory usage. This plugin can be useful for embedded systems. > > May I suggest, as a followup patch, a debug option/plugin parameter to > put the strings in a section which will not be reaped after init, but > just marked inaccessible, with graceful handling of bad accesses (print > a big fat warning, make the page(s) readable, continue)? I think even better would be to verify the whole init section. Unfortunately, I won't implement it anytime soon because my project ends this week. -- Emese