From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5307FC28CC0 for ; Wed, 29 May 2019 18:43:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2510123F61 for ; Wed, 29 May 2019 18:43:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="jegnb+b+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725956AbfE2SnK (ORCPT ); Wed, 29 May 2019 14:43:10 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:45269 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725914AbfE2SnK (ORCPT ); Wed, 29 May 2019 14:43:10 -0400 Received: by mail-pl1-f196.google.com with SMTP id x7so441851plr.12 for ; Wed, 29 May 2019 11:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=EfGbBMHYGMmn9vTu990IJy1DO6Nzjk593nZn1dz4oVk=; b=jegnb+b+gX//d0vhP3uQvq7x+sAF3QEmogXo39wiwjaOrMNfZo1hXe3LqWwdyTlEGP sLjJiDBuOiQ5XbLD/BthT+9Q0e3xSRma3rzkzRLE/SH7g1hdl3RHi25rlwNs1z+/ZU5g y/2mNWS5Qnps3vAMakm3FhuP5d/GjDu0t652o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=EfGbBMHYGMmn9vTu990IJy1DO6Nzjk593nZn1dz4oVk=; b=dlkJ6fvlvcUf83nxMjDLGSfnDqdAo2wgXskTkx+9ODmglL6QKCIjWqalwEo/iBZX7Y CX1nDWJN5IRgmIkt0HdYx1mp8+VeVIN5UtCJgd0AwyXOIIL9QwbnhIxUiqOMvRQbmSJT 2w+tx+UQlhISUyiwGC8EC/DoVCLzVDhBAJ8wr0nHwt2GiCtC2mCYQopG8qSWxfY4Ca7t 3UIuxJlaRYZ37/NK5Vle44ImIs2Q5ZUFBJz25XtG7XF3ajheeMyiFc5NlvWfbZyoPVat 4gc/F8dYQggVv8395HNSgNw+emJ/gCGytXcMbCJ/LB6j8aWcaootbX+z5zLJvrWLe7Kq P+VQ== X-Gm-Message-State: APjAAAUnb3K0f00FjfRknDXzU3w/1Fcpkg8cY8uT5ps/6M6DHHM1hGlM 9nvtaW/nILJp/8pWPAXQGbt8Ag== X-Google-Smtp-Source: APXvYqzpr7CoVb5BM/Pz1u+mLgd3ASb0jPnJQzj1N/X5EKbeo05UJH/jb1NCHGZzD/mmLzqv8VLj5Q== X-Received: by 2002:a17:902:7c08:: with SMTP id x8mr5907075pll.159.1559155389784; Wed, 29 May 2019 11:43:09 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q6sm393246pfg.7.2019.05.29.11.43.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 May 2019 11:43:08 -0700 (PDT) Date: Wed, 29 May 2019 11:43:08 -0700 From: Kees Cook To: Alexander Potapenko Cc: Andrew Morton , Christoph Lameter , Dmitry Vyukov , James Morris , Jann Horn , Kostya Serebryany , Laura Abbott , Mark Rutland , Masahiro Yamada , Matthew Wilcox , Nick Desaulniers , Randy Dunlap , Sandeep Patil , "Serge E. Hallyn" , Souptick Joarder , Marco Elver , kernel-hardening@lists.openwall.com, linux-mm@kvack.org, linux-security-module@vger.kernel.org Subject: Re: [PATCH v5 2/3] mm: init: report memory auto-initialization features at boot time Message-ID: <201905291142.E415379F2@keescook> References: <20190529123812.43089-1-glider@google.com> <20190529123812.43089-3-glider@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190529123812.43089-3-glider@google.com> Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: 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 > Suggested-by: Kees Cook Looks good to me! Acked-by: Kees Cook > To: Andrew Morton > To: Christoph Lameter > Cc: Dmitry Vyukov > Cc: James Morris > Cc: Jann Horn > Cc: Kostya Serebryany > Cc: Laura Abbott > Cc: Mark Rutland > Cc: Masahiro Yamada > Cc: Matthew Wilcox > Cc: Nick Desaulniers > Cc: Randy Dunlap > Cc: Sandeep Patil > Cc: "Serge E. Hallyn" > Cc: Souptick Joarder > Cc: Marco Elver > Cc: kernel-hardening@lists.openwall.com > Cc: linux-mm@kvack.org > Cc: linux-security-module@vger.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