@@ -2090,6 +2090,32 @@ char *fwnode_string(char *buf, char *end, struct fwnode_handle *fwnode,
20902090 return widen_string (buf , buf - buf_start , end , spec );
20912091}
20922092
2093+ /* Disable pointer hashing if requested */
2094+ bool no_hash_pointers __ro_after_init ;
2095+ EXPORT_SYMBOL_GPL (no_hash_pointers );
2096+
2097+ static int __init no_hash_pointers_enable (char * str )
2098+ {
2099+ no_hash_pointers = true;
2100+
2101+ pr_warn ("**********************************************************\n" );
2102+ pr_warn ("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n" );
2103+ pr_warn ("** **\n" );
2104+ pr_warn ("** This system shows unhashed kernel memory addresses **\n" );
2105+ pr_warn ("** via the console, logs, and other interfaces. This **\n" );
2106+ pr_warn ("** might reduce the security of your system. **\n" );
2107+ pr_warn ("** **\n" );
2108+ pr_warn ("** If you see this message and you are not debugging **\n" );
2109+ pr_warn ("** the kernel, report this immediately to your system **\n" );
2110+ pr_warn ("** administrator! **\n" );
2111+ pr_warn ("** **\n" );
2112+ pr_warn ("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n" );
2113+ pr_warn ("**********************************************************\n" );
2114+
2115+ return 0 ;
2116+ }
2117+ early_param ("no_hash_pointers" , no_hash_pointers_enable );
2118+
20932119/*
20942120 * Show a '%p' thing. A kernel extension is that the '%p' is followed
20952121 * by an extra set of alphanumeric characters that are extended format
@@ -2297,8 +2323,14 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
22972323 }
22982324 }
22992325
2300- /* default is to _not_ leak addresses, hash before printing */
2301- return ptr_to_id (buf , end , ptr , spec );
2326+ /*
2327+ * default is to _not_ leak addresses, so hash before printing,
2328+ * unless no_hash_pointers is specified on the command line.
2329+ */
2330+ if (unlikely (no_hash_pointers ))
2331+ return pointer_string (buf , end , ptr , spec );
2332+ else
2333+ return ptr_to_id (buf , end , ptr , spec );
23022334}
23032335
23042336/*
0 commit comments