aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@glider.be>2018-10-11 10:42:48 +0200
committerTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-01-10 13:03:02 +0000
commitb88d825136b172931c290ed99e517111ba0feb98 (patch)
tree3fbe742012529f7a63697222ba60a1e9a4ae64a7
parenta4873af07a5a93c3fa2bc4986006466ff2ecf091 (diff)
downloadhikey-linaro-b88d825136b172931c290ed99e517111ba0feb98.tar.gz
BACKPORT: lib/vsprintf: Hash legacy clock addresses
On platforms using the Common Clock Framework, "%pC" prints the clock's name. On legacy platforms, it prints the unhashed clock's address, potentially leaking sensitive information regarding the kernel layout in memory. Avoid this leak by printing the hashed address instead. To distinguish between clocks, a 32-bit unique identifier is as good as an actual pointer value. Bug: 254441685 Fixes: ad67b74d2469d9b8 ("printk: hash addresses printed with %p") Link: http://lkml.kernel.org/r/20181011084249.4520-3-geert+renesas@glider.be To: "Tobin C . Harding" <me@tobin.cc> To: Andrew Morton <akpm@linux-foundation.org> To: Jonathan Corbet <corbet@lwn.net> Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Petr Mladek <pmladek@suse.com> (cherry picked from commit ec12bc2909f9759747ab5ad3709472353c43a750) [Lee: Fixed a trivial conflict pertaining to original diff] Signed-off-by: Lee Jones <joneslee@google.com> Change-Id: I8286a3b34ebd66ddef861dd969c68283ef569cf5
-rw-r--r--Documentation/printk-formats.txt5
-rw-r--r--lib/vsprintf.c2
2 files changed, 3 insertions, 4 deletions
diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
index bbfeeb0813d3..25c8ad37d86c 100644
--- a/Documentation/printk-formats.txt
+++ b/Documentation/printk-formats.txt
@@ -423,9 +423,8 @@ struct clk
%pC pll1
%pCn pll1
-For printing struct clk structures. ``%pC`` and ``%pCn`` print the name
-(Common Clock Framework) or address (legacy clock framework) of the
-structure.
+For printing struct clk structures. %pC and %pCn print the name of the clock
+(Common Clock Framework) or a unique 32-bit ID (legacy clock framework).
Passed by reference.
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 516b73f2c984..5840315bf27b 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1565,7 +1565,7 @@ char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
#ifdef CONFIG_COMMON_CLK
return string(buf, end, __clk_get_name(clk), spec);
#else
- return special_hex_number(buf, end, (unsigned long)clk, sizeof(unsigned long));
+ return ptr_to_id(buf, end, clk, spec);
#endif
}
}