Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1636381pxb; Mon, 8 Mar 2021 02:35:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXEQMKAOsJCqg2WF68/rUp6Qt8KjBOXn5AydUoQeV1X21vnF+ySzUAOMFo6X+8vZ+pk0/e X-Received: by 2002:a05:6402:17af:: with SMTP id j15mr21455020edy.50.1615199701344; Mon, 08 Mar 2021 02:35:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615199701; cv=none; d=google.com; s=arc-20160816; b=FVXEKVDPgyl7Jdcr4SWFKKhaDg7CoLQnIci36qya+HEw5XQR7seCyDeAoa9wcAIAF2 dgZJj+KwOo/2Rw205oaGGx1vFakOFS8QyTpe5LaVWCxx8RGK7qA2cs2FHMmzIFNeQQPX hJ08UmgCjTtvqwYDXpke2Q52mhxXe/GIIdOCyTzMIyyuYibUGcCraLNK8i1xb5yx6HN+ csq/Un+SYi0LSVpWlSVgbFRBlZuSugTvx9PPOqRq/o1pMhoCVhbzA+HXOamifluXRCtd LaNbKhCD5UEGdzcuog1EIaSNp2Mvr5rCVQhgfxlSbr2KRX3lv0QD9G9RQjy+dTYSISCB k+6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=XFZ6QT0aFga5D7Oft1KTkVlBexQCjjaeeigUa/LcJpo=; b=MsgQJM6oSmlcE8guf/VYUfmaSVLZu8g1BqChXwH2d5qiOLolFonvqwvpMHVI3sGGt5 Bx+N0wR/OxWXxdI9yS90aGrTSmmdP+UafmzsXwfdvpOCQxyznAEpoodmKwn2uF+fcrvZ 3MQXyGi/0aj2Uya2fQbuB3kCZ92DFBpkzgFefIdJXxtxqecbUu3MzEsIE3Y1Ew0oqiND mLFhOuUO81AptPKsFZXmaF8tKPqztRYM/qQgCcXjisGxytlxq2ovJzAaMCQy5M03yRp7 O42EOmGel+HZ9zRScxhnLg9pxwnQw8+pmVgqv3FTRVcdLQZdetiVe4Ihg9y+L4dHsrNC 1ezQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c8si6322350edw.367.2021.03.08.02.34.39; Mon, 08 Mar 2021 02:35:01 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230455AbhCHKdn (ORCPT + 99 others); Mon, 8 Mar 2021 05:33:43 -0500 Received: from mga11.intel.com ([192.55.52.93]:65129 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231195AbhCHKd3 (ORCPT ); Mon, 8 Mar 2021 05:33:29 -0500 IronPort-SDR: EoydsZvAOwv0Ae03kvTUtA2gJzc0phExPZxqM8zqv/9V/LPeZ2ipYiaXCGG9awQiRVsIFFpPaT gXRMOLbcWhOw== X-IronPort-AV: E=McAfee;i="6000,8403,9916"; a="184639094" X-IronPort-AV: E=Sophos;i="5.81,232,1610438400"; d="scan'208";a="184639094" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2021 02:33:28 -0800 IronPort-SDR: HhyRFaji92hkYH/IcTXTNVLyKx6k6Odu/UMT+FJ39Nx8CtWciGdUn4pWzakHR/WhgpUNa5PyfH lQDyY3cFkM6w== X-IronPort-AV: E=Sophos;i="5.81,232,1610438400"; d="scan'208";a="385807735" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2021 02:33:26 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1lJDCV-00An4O-2k; Mon, 08 Mar 2021 12:33:23 +0200 Date: Mon, 8 Mar 2021 12:33:23 +0200 From: Andy Shevchenko To: Marco Elver Cc: linux-kernel@vger.kernel.org, vbabka@suse.cz, timur@kernel.org, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, linux@rasmusvillemoes.dk, Geert Uytterhoeven Subject: Re: [PATCH 2/2] lib/vsprintf: reduce space taken by no_hash_pointers warning Message-ID: References: <20210305194206.3165917-1-elver@google.com> <20210305194206.3165917-2-elver@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210305194206.3165917-2-elver@google.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 05, 2021 at 08:42:06PM +0100, Marco Elver wrote: > 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. This seems to have 2-in-1 patch. Care to split? Feel free to add Reviewed-by: Andy Shevchenko to the __initconst part, but the rest. > 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 > -- With Best Regards, Andy Shevchenko