Merge tag 'kbuild-v5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy...
[linux-2.6-microblaze.git] / lib / vsprintf.c
index 3b53c73..41ddc35 100644 (file)
@@ -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);
+
 /*
  * 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 +2323,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 no_hash_pointers is specified on the command line.
+        */
+       if (unlikely(no_hash_pointers))
+               return pointer_string(buf, end, ptr, spec);
+       else
+               return ptr_to_id(buf, end, ptr, spec);
 }
 
 /*