Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2288084pxb; Fri, 5 Mar 2021 11:46:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzij4VBhJysy2d9chEC0f6LEVWHD3Jgxv27CpmmxxaC5IBSW94BxBJYMnukz8d9jhBI8pRC X-Received: by 2002:aa7:c7c8:: with SMTP id o8mr10575064eds.176.1614973563085; Fri, 05 Mar 2021 11:46:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614973563; cv=none; d=google.com; s=arc-20160816; b=FTF84g4lsiT8iAJuFEqx5ijD7Vq5ad+qm0K0ljJX21B4/9N86aF0SsT8IlzT6l5JLU Ig/1+ANg2UDOBKTRrj+AYtgB6H+MBvT65soCC6mUpaVykYeGgTdsoNuvAo6laMOIJUXr GG8sQvinfNCSo60TGZEz7kYatnpMrE0deXIv+F4FLrsV53xo0BWAl0wzo3Hp61sJTr3r vaF2quRCzDQ4MlQrK8XEq4sajB+cDDN3VFU8f6XaDxx4CHSGysJhXJfpQ29pt56osGT/ u5kDJi18kLk914np4mbi9z3LV9BbLRbBM+iVH7JvF8aRjI35MsRIba6uBH4hmB6iHKU1 WAbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=FC7MxNRGLasOl0AFHOn/4f0TFFn6brVrrzJWC80/CCI=; b=YJIROGVtsj5RtbuRR+p41GDG90G54vbXiMYnWOXGb30IrRLXimoFphj7XdIyrwYGBW 73NQPvuHPo+EDl3xAzX8RqWE/7YjIknEAGkMWwMYjHbsEgL8mVQWBTbVKfENJlXnr0+B G/ba0jyaU90Q03EJBt4hgIOtEs4hQSxhZk4ZIR9pY+1ykw4U8bO1kXBneprK7sVA0eS/ Ead+hLmTdTY6EM9o3xNk883TRd5fH1LyzM28DVPzeXd5LIL9b+6KanFfuVjg33RNHhPD 6F6SCs26ei7N9xPXPC+AhcaAYsQZHPhaulxVR32PmA3xLnwk0mI0Gr359Znk6cmXYVXZ KsJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=iGuP7Jlr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y18si1816876ejj.628.2021.03.05.11.45.38; Fri, 05 Mar 2021 11:46:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=iGuP7Jlr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230094AbhCETmX (ORCPT + 99 others); Fri, 5 Mar 2021 14:42:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230183AbhCETmM (ORCPT ); Fri, 5 Mar 2021 14:42:12 -0500 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F044C06175F for ; Fri, 5 Mar 2021 11:42:12 -0800 (PST) Received: by mail-qk1-x749.google.com with SMTP id i11so2606817qkn.21 for ; Fri, 05 Mar 2021 11:42:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=FC7MxNRGLasOl0AFHOn/4f0TFFn6brVrrzJWC80/CCI=; b=iGuP7JlrJUVkJlMVhnEdtuHAVUe03G3HY0riy3nPB4gQYwXkteBuwb7WCnAeVB70Jt lSajnXmsoMPk3EP71stCS7pslmh86GDl0sNa+0tPE/lsbWMgeY+5d2yFRkbyiKrb+Wgj HFQyC9fDIscxdziiDdqAQcbJVN71AolzbwNnKhn97RtlbhzUFhQzswp5HnwBZsgSydHx IO8lwseCUT5dhhmqyl346d8tGCoWsE00Re8fn9WYGO0ogR2tPTVR0WmHDGQLjYNN+jP8 jIL9VX8mxSTqwuR7OobXv6sj+I2ZCQKMp6UoPUz/l4uQfnyBNsKFtPJnE5CmAPSGS3fo aHgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=FC7MxNRGLasOl0AFHOn/4f0TFFn6brVrrzJWC80/CCI=; b=Eku4289URx/f/YeX5cHakjWVfub4aMpC7tmlW+siTRPqNdujtyetJrFA+52gz2dUR4 7XnBkHUkrC8hZeExgzNV0rJM0CrWvUfp9FagxKebxD/JvXkZwDVthBD7x2KqaP9eBj4I rDVOXVphgHj7fADUyst0uzCkFTCtlLJccmhVYI2xf6SO0iR/kpDENXrbJaxkLA/jJCVZ 0NwoNZ2BPQsCNM7RPWLyUCDGzN7orVAOoLfqkgrVde5IGUBo2QdxznuHF1IT9k83haWx ovVc8nPDmiOXjUn8Fp3uhQ/Ln7L6FZ5U81yZ2KfbCbJXFOpGu6s5elKLkhOXy9cyjY99 5MuQ== X-Gm-Message-State: AOAM531qsuPb8K2WHlPH1mQWVjqjUNIY1DZqD/8GzP9FiFtYo8ajbCCW yOkFjKQpwujFzRz+wDPybaf9qt7/jg== Sender: "elver via sendgmr" X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:e:611c:f54a:61d6]) (user=elver job=sendgmr) by 2002:ad4:4904:: with SMTP id bh4mr10400872qvb.53.1614973331699; Fri, 05 Mar 2021 11:42:11 -0800 (PST) Date: Fri, 5 Mar 2021 20:42:06 +0100 In-Reply-To: <20210305194206.3165917-1-elver@google.com> Message-Id: <20210305194206.3165917-2-elver@google.com> Mime-Version: 1.0 References: <20210305194206.3165917-1-elver@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH 2/2] lib/vsprintf: reduce space taken by no_hash_pointers warning From: Marco Elver To: elver@google.com Cc: linux-kernel@vger.kernel.org, vbabka@suse.cz, timur@kernel.org, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, Geert Uytterhoeven Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move the no_hash_pointers warning string into __initconst section, so that it is discarded after init. Remove common start/end characters. Also remove repeated lines from the array, since the compiler can't remove duplicate strings for us since the array must appear in __initconst as defined. Note, a similar message appears in kernel/trace/trace.c, but compiling the feature is guarded by CONFIG_TRACING. It is not immediately obvious if a space-concious kernel would prefer CONFIG_TRACING=n. Therefore, it makes sense to keep the message for no_hash_pointers as __initconst, and not move the NOTICE-printing to a common function. Link: https://lkml.kernel.org/r/CAMuHMdULKZCJevVJcp7TxzLdWLjsQPhE8hqxhnztNi9bjT_cEw@mail.gmail.com Reported-by: Geert Uytterhoeven Signed-off-by: Marco Elver --- lib/vsprintf.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 4a14889ccb35..1095689c9c97 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -2094,26 +2094,30 @@ char *fwnode_string(char *buf, char *end, struct fwnode_handle *fwnode, bool no_hash_pointers __ro_after_init; EXPORT_SYMBOL_GPL(no_hash_pointers); +static const char no_hash_pointers_warning[8][55] __initconst = { + "******************************************************", + " NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE ", + " This system shows unhashed kernel memory addresses ", + " via the console, logs, and other interfaces. This ", + " might reduce the security of your system. ", + " If you see this message and you are not debugging ", + " the kernel, report this immediately to your system ", + " administrator! ", +}; + static int __init no_hash_pointers_enable(char *str) { + /* Indices into no_hash_pointers_warning; -1 is an empty line. */ + const int lines[] = { 0, 1, -1, 2, 3, 4, -1, 5, 6, 7, -1, 1, 0 }; + int i; + if (no_hash_pointers) return 0; no_hash_pointers = true; - pr_warn("**********************************************************\n"); - pr_warn("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n"); - pr_warn("** **\n"); - pr_warn("** This system shows unhashed kernel memory addresses **\n"); - pr_warn("** via the console, logs, and other interfaces. This **\n"); - pr_warn("** might reduce the security of your system. **\n"); - pr_warn("** **\n"); - pr_warn("** If you see this message and you are not debugging **\n"); - pr_warn("** the kernel, report this immediately to your system **\n"); - pr_warn("** administrator! **\n"); - pr_warn("** **\n"); - pr_warn("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n"); - pr_warn("**********************************************************\n"); + for (i = 0; i < ARRAY_SIZE(lines); i++) + pr_warn("**%54s**\n", i == -1 ? "" : no_hash_pointers_warning[lines[i]]); return 0; } -- 2.30.1.766.gb4fecdf3b7-goog