From patchwork Wed Feb 10 05:05:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 12079849 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=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 3EAA6C433E9 for ; Wed, 10 Feb 2021 05:05:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B124D64E42 for ; Wed, 10 Feb 2021 05:05:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B124D64E42 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 423ED6B0006; Wed, 10 Feb 2021 00:05:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FC046B006C; Wed, 10 Feb 2021 00:05:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C1946B0071; Wed, 10 Feb 2021 00:05:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0190.hostedemail.com [216.40.44.190]) by kanga.kvack.org (Postfix) with ESMTP id 09E8C6B0006 for ; Wed, 10 Feb 2021 00:05:57 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B02646C11 for ; Wed, 10 Feb 2021 05:05:56 +0000 (UTC) X-FDA: 77801171112.11.birth95_26031c92760d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 927921842C4BE for ; Wed, 10 Feb 2021 05:05:56 +0000 (UTC) X-HE-Tag: birth95_26031c92760d X-Filterd-Recvd-Size: 3303 Received: from hqnvemgate24.nvidia.com (hqnvemgate24.nvidia.com [216.228.121.143]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Wed, 10 Feb 2021 05:05:55 +0000 (UTC) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Tue, 09 Feb 2021 21:05:54 -0800 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 10 Feb 2021 05:05:52 +0000 Received: from ubuntu.vdiclient.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.18) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Wed, 10 Feb 2021 05:05:50 +0000 From: Timur Tabi To: Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Vlastimil Babka , Andy Shevchenko , Matthew Wilcox , , "Linus Torvalds" , , "Kees Cook" , John Ogness , , , Andrey Konovalov , Marco Elver , Rasmus Villemoes , Pavel Machek , , Subject: [PATCH 1/3] lib/test_printf: use KSTM_MODULE_GLOBALS macro Date: Tue, 9 Feb 2021 23:05:27 -0600 Message-ID: <20210210050529.843005-2-ttabi@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210050529.843005-1-ttabi@nvidia.com> References: <20210210050529.843005-1-ttabi@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1612933554; bh=kgyfjShF7mas8HBfojx7GJ3B/MiEwf776XombejL4M0=; h=From:To:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:X-NVConfidentiality:Content-Transfer-Encoding: Content-Type; b=B+No78WC4/4cq4n39fV7wS6lKmasY1HNrGKRE8EgL459sjJiquKLPlRF8KeQChA5x 5WM5kZ3N3EosHqSbpFF+vpmfdvLu6SkTuwcD4HrXm/0p4Asc08JzFTtGLSNMZtfl52 aG+PgI2xNgpvcwX6+LzKCpdTShhp8mkiAM9DDqVhqjCCnc6trZbMUvTVTUu701yYec Du0cdwsssXgK8uqvjxFrBooZy6ul/vOweYPGzvUA1kdbbxu+5emYNE5/vaKdp23mL8 XPHscqJbogHd5v5A2vJoPT/cpIo8FfHPGPm+YN1MRYNZRjFrXfSp7u0LzHONcMgvVk v/vFQnl+7gIUw== 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: Instead of defining the total/failed test counters manually, test_printf should use the kselftest macro created for this purpose. Signed-off-by: Timur Tabi --- lib/test_printf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/test_printf.c b/lib/test_printf.c index 7ac87f18a10f..ad2bcfa8caa1 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -30,8 +30,8 @@ #define PAD_SIZE 16 #define FILL_CHAR '$' -static unsigned total_tests __initdata; -static unsigned failed_tests __initdata; +KSTM_MODULE_GLOBALS(); + static char *test_buffer __initdata; static char *alloced_buffer __initdata; From patchwork Wed Feb 10 05:05:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 12079851 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=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 36399C433DB for ; Wed, 10 Feb 2021 05:06:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DF00264E42 for ; Wed, 10 Feb 2021 05:06:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF00264E42 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 75BC86B006C; Wed, 10 Feb 2021 00:06:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E0BC6B0070; Wed, 10 Feb 2021 00:06:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F9A36B0071; Wed, 10 Feb 2021 00:06:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id 489736B006C for ; Wed, 10 Feb 2021 00:06:02 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 08FEB18478DB5 for ; Wed, 10 Feb 2021 05:06:02 +0000 (UTC) X-FDA: 77801171364.21.drum17_4a0cf2d2760d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id E3C9A184B4AE0 for ; Wed, 10 Feb 2021 05:06:01 +0000 (UTC) X-HE-Tag: drum17_4a0cf2d2760d X-Filterd-Recvd-Size: 4531 Received: from hqnvemgate26.nvidia.com (hqnvemgate26.nvidia.com [216.228.121.65]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Wed, 10 Feb 2021 05:06:01 +0000 (UTC) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Tue, 09 Feb 2021 21:05:59 -0800 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 10 Feb 2021 05:05:55 +0000 Received: from ubuntu.vdiclient.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.18) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Wed, 10 Feb 2021 05:05:53 +0000 From: Timur Tabi To: Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Vlastimil Babka , Andy Shevchenko , Matthew Wilcox , , "Linus Torvalds" , , "Kees Cook" , John Ogness , , , Andrey Konovalov , Marco Elver , Rasmus Villemoes , Pavel Machek , , Subject: [PATCH 2/3] kselftest: add support for skipped tests Date: Tue, 9 Feb 2021 23:05:28 -0600 Message-ID: <20210210050529.843005-3-ttabi@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210050529.843005-1-ttabi@nvidia.com> References: <20210210050529.843005-1-ttabi@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1612933559; bh=zziyNFNlmhSW3q56XQBsPtG1JAzI0NtMX6ixBkt95eQ=; h=From:To:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:X-NVConfidentiality:Content-Transfer-Encoding: Content-Type; b=WuvKaTC/TNCklMdz1K6fO9lcupEAM8iorDm0grzyrVo1mbY49/SVyPj5vGk6daZ4J rRliDzP37cebsuJALnMxasmn2wBY1WDF1B9amiof1HqKKZ66KFSri+L/lkUHT7P0Rc Q8BYd8ockVYDukRfdLgHlgaAZiKDajU9Sl6t3C/4H/gnMnuSxNY9F6L/yvIl2ioc0/ 343SsdMWuSJxoarnaxNMDriDATmjtCIDLX+5/7toogK5q87jCYHW9IbUYV3a7aRMND QSdjyudXOnFz0V/hrcO3TbcntXS+iaO5EGmLMSVX+tgdIvKRVro7pvqhtGw6wmZKM4 pwVlPM7v9v30Q== 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: Update the kselftest framework to all testing clients to specify that some tests were skipped. Signed-off-by: Timur Tabi --- tools/testing/selftests/kselftest_module.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/kselftest_module.h b/tools/testing/selftests/kselftest_module.h index e8eafaf0941a..e2ea41de3f35 100644 --- a/tools/testing/selftests/kselftest_module.h +++ b/tools/testing/selftests/kselftest_module.h @@ -11,7 +11,8 @@ #define KSTM_MODULE_GLOBALS() \ static unsigned int total_tests __initdata; \ -static unsigned int failed_tests __initdata +static unsigned int failed_tests __initdata; \ +static unsigned int skipped_tests __initdata #define KSTM_CHECK_ZERO(x) do { \ total_tests++; \ @@ -21,11 +22,16 @@ static unsigned int failed_tests __initdata } \ } while (0) -static inline int kstm_report(unsigned int total_tests, unsigned int failed_tests) +static inline int kstm_report(unsigned int total_tests, unsigned int failed_tests, + unsigned int skipped_tests) { - if (failed_tests == 0) - pr_info("all %u tests passed\n", total_tests); - else + if (failed_tests == 0) { + if (skipped_tests) { + pr_info("skipped %u tests\n", skipped_tests); + pr_info("remaining %u tests passed\n", total_tests); + } else + pr_info("all %u tests passed\n", total_tests); + } else pr_warn("failed %u out of %u tests\n", failed_tests, total_tests); return failed_tests ? -EINVAL : 0; @@ -36,7 +42,7 @@ static int __init __module##_init(void) \ { \ pr_info("loaded.\n"); \ selftest(); \ - return kstm_report(total_tests, failed_tests); \ + return kstm_report(total_tests, failed_tests, skipped_tests); \ } \ static void __exit __module##_exit(void) \ { \ From patchwork Wed Feb 10 05:05:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 12079853 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=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 1AEACC433E6 for ; Wed, 10 Feb 2021 05:06:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A8C2C64DA5 for ; Wed, 10 Feb 2021 05:06:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A8C2C64DA5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 77EE76B0070; Wed, 10 Feb 2021 00:06:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 731A56B0071; Wed, 10 Feb 2021 00:06:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5FAAC6B0072; Wed, 10 Feb 2021 00:06:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0032.hostedemail.com [216.40.44.32]) by kanga.kvack.org (Postfix) with ESMTP id 46BD56B0070 for ; Wed, 10 Feb 2021 00:06:03 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 0C1D58248076 for ; Wed, 10 Feb 2021 05:06:03 +0000 (UTC) X-FDA: 77801171406.05.cow14_43166392760d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id DC41E1848BB1B for ; Wed, 10 Feb 2021 05:06:02 +0000 (UTC) X-HE-Tag: cow14_43166392760d X-Filterd-Recvd-Size: 7984 Received: from hqnvemgate25.nvidia.com (hqnvemgate25.nvidia.com [216.228.121.64]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Wed, 10 Feb 2021 05:06:02 +0000 (UTC) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Tue, 09 Feb 2021 21:06:01 -0800 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 10 Feb 2021 05:05:57 +0000 Received: from ubuntu.vdiclient.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.18) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Wed, 10 Feb 2021 05:05:55 +0000 From: Timur Tabi To: Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Vlastimil Babka , Andy Shevchenko , Matthew Wilcox , , "Linus Torvalds" , , "Kees Cook" , John Ogness , , , Andrey Konovalov , Marco Elver , Rasmus Villemoes , Pavel Machek , , Subject: [PATCH 3/3] [v2] lib/vsprintf: make-printk-non-secret printks all addresses as unhashed Date: Tue, 9 Feb 2021 23:05:29 -0600 Message-ID: <20210210050529.843005-4-ttabi@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210210050529.843005-1-ttabi@nvidia.com> References: <20210210050529.843005-1-ttabi@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1612933561; bh=nILtLouqYG0ZxaviM/LyTLNoaremqp+z19s7vgq4xqE=; h=From:To:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:X-NVConfidentiality:Content-Transfer-Encoding: Content-Type; b=P5hUKCXwzU4Hyxh56q/GOc+d92gKvj1odqsEuGop7CfzykReMs+KyLqcNl6TKcGRb dqllFJQll9W4jw366WrtBKRO+56qb3HpoR/R2Wbt80fNNd5g+nc7t11T1snhoj104o ot99XNNAXv2oHZ1cn/JDYCHO7RXENbIqW+mSFgyBtxmbf6EnbCJPpbXOS5ifNdGuJK NxGkXlW/sEoeuky7/di3sLZ1PcMfwHQzIR7UHLkn3ed9GTqfs7yZRa1oekE6sLL+ji 4m4PYQCykC8Fyj4GrEBeA7GogawaLM3yHERqwRZ1ZHxzk/I8MT1pKeFxiVD8NPkP7C EmQgxSdTWs4Lg== 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: From: Timur Tabi If the make-printk-non-secret command line parameter is set, then printk("%p") will print pointers as unhashed. This is useful for debugging purposes. A large warning message is displayed if this option is enabled. Unhashed pointers, while useful for debugging, 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 Acked-by: Petr Mladek Acked-by: Randy Dunlap Acked-by: Sergey Senozhatsky --- .../admin-guide/kernel-parameters.txt | 15 ++++++++ lib/test_printf.c | 8 ++++ lib/vsprintf.c | 38 ++++++++++++++++++- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 9e3cdb271d06..e639b0f32a6c 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2613,6 +2613,21 @@ different yeeloong laptops. Example: machtype=lemote-yeeloong-2f-7inch + make-printk-non-secret + Force pointers printed to the console to be unhashed. + By default, when a pointer is printed to the kernel + console (via %p format string), that pointer is + "hashed", i.e. obscured by hashing the pointer value. + This is a security feature that hides actual kernel + addresses from unprivileged users, but it also makes + debugging the kernel more difficult since unequal + pointers can no longer be compared. If this option is + specified, then all normal pointers will have their + true value printed. Pointers printed via %pK may + still be hashed. This option should only be specified + when debugging the kernel. Please do not use on + production kernels. + max_addr=nn[KMG] [KNL,BOOT,ia64] All physical memory greater than or equal to this physical address is ignored. diff --git a/lib/test_printf.c b/lib/test_printf.c index ad2bcfa8caa1..b0b62d76e598 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -35,6 +35,8 @@ KSTM_MODULE_GLOBALS(); static char *test_buffer __initdata; static char *alloced_buffer __initdata; +extern bool debug_never_hash_pointers; + static int __printf(4, 0) __init do_test(int bufsize, const char *expect, int elen, const char *fmt, va_list ap) @@ -301,6 +303,12 @@ plain(void) { int err; + if (debug_never_hash_pointers) { + pr_warn("skipping plain 'p' tests"); + skipped_tests += 2; + return; + } + err = plain_hash(); if (err) { pr_warn("plain 'p' does not appear to be hashed\n"); diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 3b53c73580c5..1296d9b0b328 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -2090,6 +2090,34 @@ 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 debug_never_hash_pointers __ro_after_init; +EXPORT_SYMBOL_GPL(debug_never_hash_pointers); + +static int __init debug_never_hash_pointers_enable(char *str) +{ + debug_never_hash_pointers = true; + + pr_warn("**********************************************************\n"); + pr_warn("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n"); + pr_warn("** **\n"); + pr_warn("** All pointers that are printed to the console will **\n"); + pr_warn("** be printed as unhashed. **\n"); + pr_warn("** **\n"); + pr_warn("** Kernel memory addresses are exposed, which may **\n"); + pr_warn("** 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("make-printk-non-secret", debug_never_hash_pointers_enable); + /* * Show a '%p' thing. A kernel extension is that the '%p' is followed * by an extra set of alphanumeric characters that are extended format @@ -2297,8 +2325,14 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, } } - /* default is to _not_ leak addresses, hash before printing */ - return ptr_to_id(buf, end, ptr, spec); + /* + * default is to _not_ leak addresses, so hash before printing unless + * make-printk-non-secret is specified on the command line. + */ + if (unlikely(debug_never_hash_pointers)) + return pointer_string(buf, end, ptr, spec); + else + return ptr_to_id(buf, end, ptr, spec); } /*