From patchwork Wed May 29 12:38:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 10967025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 42216933 for ; Wed, 29 May 2019 12:38:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D6D628989 for ; Wed, 29 May 2019 12:38:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B3462899B; Wed, 29 May 2019 12:38:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90E9A28989 for ; Wed, 29 May 2019 12:38:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7111F6B000D; Wed, 29 May 2019 08:38:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6C29F6B000E; Wed, 29 May 2019 08:38:34 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B18F6B0010; Wed, 29 May 2019 08:38:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by kanga.kvack.org (Postfix) with ESMTP id 35DA46B000D for ; Wed, 29 May 2019 08:38:34 -0400 (EDT) Received: by mail-qt1-f198.google.com with SMTP id 28so1802832qtw.5 for ; Wed, 29 May 2019 05:38:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=OTSVci+9HQFGuKiIh59lqpYGkMYL4TSES3kfTgmqHdU=; b=b7Z2YnGDWnJwOWGLcxxB2LHRCe5TQHof1pQenMkcfjJYZslQROkJps0rdaCMvb5On/ ZROZt8y5SovcZYhQRi/yVBPOH51uNjpJjywmSRaecuZAKTyTztvBCIlLREmc+6FKdpXK MKytKrFLYl4dhebzEFby/Pbg7PASnRfqTp649gaUY2ShtyZhRUvVhDuhY8/Y3LvTpC1O yWqXf8n7ATAWb3Jp7krMLjDJ44G1zJerKtpTOOsCpKyY9uReqKhgi0hMNJ47r9VTkJ4M Ou1vbA3IiKzk6opm1yt6jr2KHDqeEUWApPAI+KwQs7ogHLXvTXaQ2hoTplE2hH4W0Qg4 LYWw== X-Gm-Message-State: APjAAAXlb/U3+iCn98o3i74N/N0GHr9BGCvDwJip5oGvKJ0zpgpjfK6d weaekG3Co6aug5FoTvqB+qiguYVwAJgcmrUNRqbRsk05fm4qD9t1OfPAQSU07PdRTNKvd5oWd8P 8zNkBMEAu95mw8PUjdwDS7k8exjN4GsHkdQdSaFAKecShidkz9cJeVcpnxp8iNfAlUg== X-Received: by 2002:aed:2383:: with SMTP id j3mr10796766qtc.313.1559133513985; Wed, 29 May 2019 05:38:33 -0700 (PDT) X-Received: by 2002:aed:2383:: with SMTP id j3mr10796721qtc.313.1559133513393; Wed, 29 May 2019 05:38:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559133513; cv=none; d=google.com; s=arc-20160816; b=Y2Qhe/Iz9pLRpsrUV0YZkL4P8cBeTP46RfqCVtQlCUDOHrVaOP+mEDJR95MdiLugCj RJxmnWhZ9ZdXdwsphQVJbSrRAtUk8bO369BoxSoKEKvflN9OvF2pYUQbU56kagv44BM3 unbCwfIJv4jEiOlIZax6vJ0GyegiRjwI6+NF+JZaKL957/ySYzOfXhJlpCnWdu+iKnfR Ki+tdy/REUF2v60iYy7XDvld+1Cm48DJS4q6NElV9mdisdjXu0MoKdofzgzPozrq2aCN JAMjiGxzCaueJrVAlD2jigF/sCnuS4K+w0gnj99KmFqflSkTgdk5mVSv/ATx6V1Y5GQM OmHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:dkim-signature; bh=OTSVci+9HQFGuKiIh59lqpYGkMYL4TSES3kfTgmqHdU=; b=HfVsj850a34o2Gjdk88TIcTEPs5ec/Mh/Jwat4nsAA03dRPBih6O3pbWdZHraCb1dK Y1a3Al1lfW/xP0vLZoLUTPjtKjC2bMTnlG13ahDKPOwIAqxWAYWwL/mUniRqLec4gD9j K/wBxIpss0EIkwOQwKtJCvfIJejZefO2X9RctbSgy1UrEMAxtCK+ZHFt/qfSs2Dxi9V8 xt1+rJ4QsKxcCtXTREOKXWWQ6IgDbJBapHd9mbrGkoy0jHlYykyRJYugt8xTqqOutkBQ qmnvkUNFoGY4mOhn2fe9yWDys+hAFJo4OE/zmF3h0kWRGyY+H4fyvEshomZ1mVG/qfAf kqPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=QVUrmXjB; spf=pass (google.com: domain of 3sx3uxaykcoosxupqdsaasxq.oayxuzgj-yywhmow.ads@flex--glider.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3SX3uXAYKCOoSXUPQdSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--glider.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f73.google.com (mail-sor-f73.google.com. [209.85.220.73]) by mx.google.com with SMTPS id m13sor8948553qkg.139.2019.05.29.05.38.33 for (Google Transport Security); Wed, 29 May 2019 05:38:33 -0700 (PDT) Received-SPF: pass (google.com: domain of 3sx3uxaykcoosxupqdsaasxq.oayxuzgj-yywhmow.ads@flex--glider.bounces.google.com designates 209.85.220.73 as permitted sender) client-ip=209.85.220.73; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=QVUrmXjB; spf=pass (google.com: domain of 3sx3uxaykcoosxupqdsaasxq.oayxuzgj-yywhmow.ads@flex--glider.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3SX3uXAYKCOoSXUPQdSaaSXQ.OaYXUZgj-YYWhMOW.adS@flex--glider.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=OTSVci+9HQFGuKiIh59lqpYGkMYL4TSES3kfTgmqHdU=; b=QVUrmXjBtd4xAGA041VU9vn2Wo24J0G/ryDcfbSzyIaXXA9eT1e/5dNi0QJEzMBCWq fN3WkgM5gqMR9l0iwxBy9vH+tbNaCYmzc3eMgJngHj1kSa5AtgjWh5+5HjO/QfCZpvY6 Jb+OfcJFPlWhCrVMcT9BX7VIzn5XFynOaCCkftBB3mbVd1JQuJaHm0m7kyXHACmQ9cgW 9zAnA35gH0p0YX9UacAq6LYdKrQ3NUIsIStqgl+m5S9sxABy/LK6SgMc6qA6s4YfiEYT SjwPmB5DRuLJ/T8J4jYw4vuR8yqEzw06eiiDOGT9MuQeYfiVfkXQYF9mVBXb/uZL2taU nQYA== X-Google-Smtp-Source: APXvYqyuj6WNrP123438HFtnTx32oR/o63x7jglpOtKNMGuuQ+g2SgRyW1Nxym/uXkKBa07I2QYAnrLim8k= X-Received: by 2002:a05:620a:141a:: with SMTP id d26mr6791202qkj.32.1559133513103; Wed, 29 May 2019 05:38:33 -0700 (PDT) Date: Wed, 29 May 2019 14:38:11 +0200 In-Reply-To: <20190529123812.43089-1-glider@google.com> Message-Id: <20190529123812.43089-3-glider@google.com> Mime-Version: 1.0 References: <20190529123812.43089-1-glider@google.com> X-Mailer: git-send-email 2.22.0.rc1.257.g3120a18244-goog Subject: [PATCH v5 2/3] mm: init: report memory auto-initialization features at boot time From: Alexander Potapenko To: Andrew Morton , Christoph Lameter Cc: Alexander Potapenko , Kees Cook , 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 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 Acked-by: Kees Cook --- 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();