Skip to content

Commit ec12bc2

Browse files
geertupmladek
authored andcommitted
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. Fixes: ad67b74 ("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>
1 parent 9073dac commit ec12bc2

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

Documentation/core-api/printk-formats.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,8 @@ struct clk
420420
%pC pll1
421421
%pCn pll1
422422

423-
For printing struct clk structures. %pC and %pCn print the name
424-
(Common Clock Framework) or address (legacy clock framework) of the
425-
structure.
423+
For printing struct clk structures. %pC and %pCn print the name of the clock
424+
(Common Clock Framework) or a unique 32-bit ID (legacy clock framework).
426425

427426
Passed by reference.
428427

lib/vsprintf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
15631563
#ifdef CONFIG_COMMON_CLK
15641564
return string(buf, end, __clk_get_name(clk), spec);
15651565
#else
1566-
return special_hex_number(buf, end, (unsigned long)clk, sizeof(unsigned long));
1566+
return ptr_to_id(buf, end, clk, spec);
15671567
#endif
15681568
}
15691569
}

0 commit comments

Comments
 (0)