Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 29 May 2019 11:43:08 -0700
From: Kees Cook <keescook@...omium.org>
To: Alexander Potapenko <glider@...gle.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
	Christoph Lameter <cl@...ux.com>,
	Dmitry Vyukov <dvyukov@...gle.com>,
	James Morris <jmorris@...ei.org>, Jann Horn <jannh@...gle.com>,
	Kostya Serebryany <kcc@...gle.com>,
	Laura Abbott <labbott@...hat.com>,
	Mark Rutland <mark.rutland@....com>,
	Masahiro Yamada <yamada.masahiro@...ionext.com>,
	Matthew Wilcox <willy@...radead.org>,
	Nick Desaulniers <ndesaulniers@...gle.com>,
	Randy Dunlap <rdunlap@...radead.org>,
	Sandeep Patil <sspatil@...roid.com>,
	"Serge E. Hallyn" <serge@...lyn.com>,
	Souptick Joarder <jrdr.linux@...il.com>,
	Marco Elver <elver@...gle.com>, kernel-hardening@...ts.openwall.com,
	linux-mm@...ck.org, linux-security-module@...r.kernel.org
Subject: Re: [PATCH v5 2/3] mm: init: report memory auto-initialization
 features at boot time

On Wed, May 29, 2019 at 02:38:11PM +0200, Alexander Potapenko wrote:
> Print the currently enabled stack and heap initialization modes.
> 
> The possible options for stack are:
>  - "all" for CONFIG_INIT_STACK_ALL;
>  - "byref_all" for CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL;
>  - "byref" for CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF;
>  - "__user" for CONFIG_GCC_PLUGIN_STRUCTLEAK_USER;
>  - "off" otherwise.
> 
> Depending on the values of init_on_alloc and init_on_free boottime
> options we also report "heap alloc" and "heap free" as "on"/"off".
> 
> In the init_on_free mode initializing pages at boot time may take some
> time, so print a notice about that as well.
> 
> Signed-off-by: Alexander Potapenko <glider@...gle.com>
> Suggested-by: Kees Cook <keescook@...omium.org>

Looks good to me!

Acked-by: Kees Cook <keescook@...omium.org>

> To: Andrew Morton <akpm@...ux-foundation.org>
> To: Christoph Lameter <cl@...ux.com>
> Cc: Dmitry Vyukov <dvyukov@...gle.com>
> Cc: James Morris <jmorris@...ei.org>
> Cc: Jann Horn <jannh@...gle.com>
> Cc: Kostya Serebryany <kcc@...gle.com>
> Cc: Laura Abbott <labbott@...hat.com>
> Cc: Mark Rutland <mark.rutland@....com>
> Cc: Masahiro Yamada <yamada.masahiro@...ionext.com>
> Cc: Matthew Wilcox <willy@...radead.org>
> Cc: Nick Desaulniers <ndesaulniers@...gle.com>
> Cc: Randy Dunlap <rdunlap@...radead.org>
> Cc: Sandeep Patil <sspatil@...roid.com>
> Cc: "Serge E. Hallyn" <serge@...lyn.com>
> Cc: Souptick Joarder <jrdr.linux@...il.com>
> Cc: Marco Elver <elver@...gle.com>
> Cc: kernel-hardening@...ts.openwall.com
> Cc: linux-mm@...ck.org
> Cc: linux-security-module@...r.kernel.org
> ---
>  init/main.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/init/main.c b/init/main.c
> index 66a196c5e4c3..9d63ff1d48f3 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -520,6 +520,29 @@ static inline void initcall_debug_enable(void)
>  }
>  #endif
>  
> +/* Report memory auto-initialization states for this boot. */
> +void __init report_meminit(void)
> +{
> +	const char *stack;
> +
> +	if (IS_ENABLED(CONFIG_INIT_STACK_ALL))
> +		stack = "all";
> +	else if (IS_ENABLED(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL))
> +		stack = "byref_all";
> +	else if (IS_ENABLED(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF))
> +		stack = "byref";
> +	else if (IS_ENABLED(CONFIG_GCC_PLUGIN_STRUCTLEAK_USER))
> +		stack = "__user";
> +	else
> +		stack = "off";
> +
> +	pr_info("mem auto-init: stack:%s, heap alloc:%s, heap free:%s\n",
> +		stack, want_init_on_alloc(GFP_KERNEL) ? "on" : "off",
> +		want_init_on_free() ? "on" : "off");
> +	if (want_init_on_free())
> +		pr_info("Clearing system memory may take some time...\n");
> +}
> +
>  /*
>   * Set up kernel memory allocators
>   */
> @@ -530,6 +553,7 @@ static void __init mm_init(void)
>  	 * bigger than MAX_ORDER unless SPARSEMEM.
>  	 */
>  	page_ext_init_flatmem();
> +	report_meminit();
>  	mem_init();
>  	kmem_cache_init();
>  	pgtable_init();
> -- 
> 2.22.0.rc1.257.g3120a18244-goog
> 

-- 
Kees Cook

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.