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=-3.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 1106CC433E6 for ; Tue, 2 Mar 2021 17:40:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CCB0464F04 for ; Tue, 2 Mar 2021 17:40:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349864AbhCBRhL (ORCPT ); Tue, 2 Mar 2021 12:37:11 -0500 Received: from mail-pl1-f170.google.com ([209.85.214.170]:45211 "EHLO mail-pl1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384553AbhCBPFU (ORCPT ); Tue, 2 Mar 2021 10:05:20 -0500 Received: by mail-pl1-f170.google.com with SMTP id u18so5997704plc.12 for ; Tue, 02 Mar 2021 07:04:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/3D/HygHM2s+B6WKXxJW0gcme/YrKFpE/BZDVmFOXmQ=; b=NiZarwH5IpCJp+U+uWnqs9OOtUZEO6+M7apZvEUXLpwW1SdAaVFvnbHOR0QJt719fH YKyirTUkBtFiVdYiOFs6s43VUvvmL+EgrIvpaporMICV+0NYQVZzptSZYHVKgD7hLUQL HFFbC9shBTUkMzPhatTu6OIAQefRDSZouWN6zoHbPdOENPl6rdk5HWl+kL4F2+ERpqKB +ydDM5bxT6l454rglntcKIbHKdvlX04T2usbFskhyWFrxI3TapDdrnXNc3RDbt5+y93+ X4Nwhg1w0XcvfwkaKtQrt//lbTc0DigUIh7nnCBmH/ofJhd3c0uLXzqgXVlyrrWuhKwP Ivpw== X-Gm-Message-State: AOAM533EHAD00x5XtknH/8PYpvt2iroK0hYHUZtZMefBBVIl4AgS1Bqp 7OE74d/b1QM4dheVJy7gFVkBd8yeD0yvDsD5M1YoJBiP X-Google-Smtp-Source: ABdhPJw1jM5JpKvKQapQ9Rs7SNql7MW5tlyO9yX/7Nr8OAiDAp7sVMIwEtQ1GtZMcXVYRbWnMbZoO/zxBcFb/v7UiD4= X-Received: by 2002:a1f:2502:: with SMTP id l2mr2306082vkl.5.1614696934432; Tue, 02 Mar 2021 06:55:34 -0800 (PST) MIME-Version: 1.0 References: <20210214161348.369023-1-timur@kernel.org> <20210214161348.369023-4-timur@kernel.org> <8893ff08-1e50-316c-f632-cd37be1690d5@suse.cz> <20210302090811.620ae7d0@gandalf.local.home> <20210302143516.GY2723601@casper.infradead.org> In-Reply-To: From: Geert Uytterhoeven Date: Tue, 2 Mar 2021 15:55:23 +0100 Message-ID: Subject: Re: [PATCH 3/3] [v4] lib/vsprintf: no_hash_pointers prints all addresses as unhashed To: Marco Elver Cc: Matthew Wilcox , Steven Rostedt , Vlastimil Babka , Petr Mladek , Timur Tabi , Sergey Senozhatsky , Andy Shevchenko , Andrew Morton , Linus Torvalds , roman.fietze@magna.com, Kees Cook , John Ogness , Akinobu Mita , Alexander Potapenko , Andrey Konovalov , Rasmus Villemoes , Pavel Machek , Tetsuo Handa , Linux Kernel Mailing List , Linux MM Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marco, On Tue, Mar 2, 2021 at 3:40 PM Marco Elver wrote: > On Tue, 2 Mar 2021 at 15:35, Matthew Wilcox wrote: > > On Tue, Mar 02, 2021 at 03:26:50PM +0100, Marco Elver wrote: > > > +static const char no_hash_pointers_warning[9][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) > > > { > > > + const int lines[] = { 0, 1, 2, 3, 4, 5, 2, 6, 7, 8, 2, 1, 0 }; > > > + int i; > > > + > > > 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("**%s**\n", no_hash_pointers_warning[lines[i]]); > > > > + for (i = 0; i < 3; i++) > > + pr_warn("**%s**\n", no_hash_pointers_warning[lines[2 - i]]); > > Yeah, I had that before, but then wanted to deal with the blank line > in the middle of the thing. So I just went with the lines array above, > which seemed cleanest for dealing with the middle blank line and > footer. Or maybe there's something even nicer I missed? :-) Gcc deduplicates the identical strings, so you don't have to go through a double indirection at all? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds