Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp952468pxb; Wed, 3 Mar 2021 22:18:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyc7hokGx9xBucvY5Aqs8LUhn3RRGHIUvG9CtjphU4ulNLnsJLZHE00hqbXXH9meYssERR5 X-Received: by 2002:a17:906:380b:: with SMTP id v11mr2555405ejc.183.1614838726630; Wed, 03 Mar 2021 22:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614838726; cv=none; d=google.com; s=arc-20160816; b=k1xu/Bj01lTRijoz0/HKrpHLck9LCmjMZCxD3h3mAoNhHU5G4wlrltlOSmXL+Na6VM bLu0OQNJvJsBtaUaiwy6tW2w4xto8qlhF88GIse18mBXcMXJ6S5/a9svuA6EHMtKgSKg 6iv/PFNUMJsUl9E7T+MvFruiUWEFJPdTZzLxxaz6EQt+iKdnmZRP0lXUzTcNOgmd3QIX ADy3s2wMSA5THNDbVbfmr9rEl1DikcgcVjytT7Kyu5Oz941H5+ssdffEGkxJA/sQMe+A vRyupd5aBvOXv5CjzlWyVuL0RKlu6piUwuaDQPhzyAk0YFydgsLAAFuU2JMSocuy2o5I j0XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=fPMYrPE53JPDiUgSdMHwbiAuGODFtR/r/Eavu/kjlTE=; b=iW03+eS08UEgBh8UCjd35sRzv8Jo8/OWGElWfVSrVuwL/WpfSnorbICUrTAYuMNlq1 R7Zb8dM/ZIkLSRDxMWx0ZExeCltllxdTOTutwS/M77AdjgMQFTIUKnL8EjErT+PALLRa O9c5duzLTNdhPXdllejUoxNnYiSZjfNuq+T473QvgZKzqvrl+FW6bOB+uI0sG9eAk3I6 wqJclpzBW5+bQ6mSJ2zG59n0RCofqX3sCGIPCVH2jq5yy3NItKXgg2k7wziKfTGIYY1u VD3bQpvKx0vzqqB2VSASU7cWDeGhWQ8dtAM6/IIrb4GRbRQ6HQ8T+5/+vz1pZVeJjiKP RVyQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p23si17011648edw.196.2021.03.03.22.18.24; Wed, 03 Mar 2021 22:18:46 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444852AbhCBMiT (ORCPT + 99 others); Tue, 2 Mar 2021 07:38:19 -0500 Received: from mail-pl1-f177.google.com ([209.85.214.177]:40291 "EHLO mail-pl1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243566AbhCBMAU (ORCPT ); Tue, 2 Mar 2021 07:00:20 -0500 Received: by mail-pl1-f177.google.com with SMTP id z7so11897723plk.7 for ; Tue, 02 Mar 2021 03:59:43 -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=fPMYrPE53JPDiUgSdMHwbiAuGODFtR/r/Eavu/kjlTE=; b=eG/AQNkW2s9thvAZyqYKtR+1Oeo4/HJR0ygHthCQQlyH6iCocDLPbv/hu4Onkdqty7 rXUAFJ+ZENZfMQ3l+CjOwF8CufU7sG3csfk9D65XJ0WMXe/6JcIlI7iFyfQH0ydQZYEc LFW1rxJfRAnpdVk71EnjHiUHTTSOf5rxhMUV7DF/3QqmXsGgwn5T6xKG+sYzAr2lO2XS k4kmBZHZk9+BGULhE/N51cA4eIVsoqVnlqSslL2dSjbbe1roSQV5erB6xVsG4QiVjkUl jXWibmos6lEMyjKNAWeEPoAtb65jR7JGhNnCySO9RrvcdiD95MmRRiuBjG9iM7bK7wjA Y5xQ== X-Gm-Message-State: AOAM533f+tB5gvjQ1dPKRHgXFXqy4Uow89dfGESI2ORzHyNhi6HNeeSl UfPHUHn+P+KSTDxqX+nwwXsXDObSGO3iKKXrNn+WY3nzQGc= X-Received: by 2002:a67:fe90:: with SMTP id b16mr1936543vsr.40.1614685915222; Tue, 02 Mar 2021 03:51:55 -0800 (PST) MIME-Version: 1.0 References: <20210214161348.369023-1-timur@kernel.org> <20210214161348.369023-4-timur@kernel.org> In-Reply-To: <20210214161348.369023-4-timur@kernel.org> From: Geert Uytterhoeven Date: Tue, 2 Mar 2021 12:51:44 +0100 Message-ID: Subject: Re: [PATCH 3/3] [v4] lib/vsprintf: no_hash_pointers prints all addresses as unhashed To: Timur Tabi Cc: Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Vlastimil Babka , Andy Shevchenko , Matthew Wilcox , Andrew Morton , Linus Torvalds , roman.fietze@magna.com, Kees Cook , John Ogness , Akinobu Mita , Alexander Potapenko , Andrey Konovalov , Marco Elver , 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 Timur, On Sun, Feb 14, 2021 at 5:17 PM Timur Tabi wrote: > If the no_hash_pointers command line parameter is set, then > printk("%p") will print pointers as unhashed, which is useful for > debugging purposes. This change applies to any function that uses > vsprintf, such as print_hex_dump() and seq_buf_printf(). > > A large warning message is displayed if this option is enabled. > Unhashed pointers expose kernel addresses, which can be a security > risk. > > Also update test_printf to skip the hashed pointer tests if the > command-line option is set. > > Signed-off-by: Timur Tabi Thanks for your patch, which is now commit 5ead723a20e0447b ("lib/vsprintf: no_hash_pointers prints all addresses as unhashed") in v5.12-rc1. > --- a/lib/vsprintf.c > +++ b/lib/vsprintf.c > @@ -2090,6 +2090,32 @@ char *fwnode_string(char *buf, char *end, struct fwnode_handle *fwnode, > return widen_string(buf, buf - buf_start, end, spec); > } > > +/* Disable pointer hashing if requested */ > +bool no_hash_pointers __ro_after_init; > +EXPORT_SYMBOL_GPL(no_hash_pointers); > + > +static int __init no_hash_pointers_enable(char *str) > +{ > + 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"); > + > + return 0; > +} > +early_param("no_hash_pointers", no_hash_pointers_enable); While bloat-o-meter is not smart enough to notice the real size impact, this does add more than 500 bytes of string data to the kernel. Do we really need such a large message? Perhaps the whole no_hash_pointers machinery should be protected by "#ifdef CONFIG_DEBUG_KERNEL"? 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