Skip to contentSkip to conversation

printk-hash-addresses-printed-with-%p.patch removed from -mm tree

merged [email protected] 1 participant 1 message Nov 30, 2017

lore
Share & tools
lore

[email protected]

author tree notice Applied
#0 lore raw

The patch titled
Subject: printk: hash addresses printed with %p
has been removed from the -mm tree. Its filename was
printk-hash-addresses-printed-with-%p.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: "Tobin C. Harding" <[email protected]>
Subject: printk: hash addresses printed with %p

Currently there exist approximately 14 000 places in the kernel where addresses are being printed using an unadorned %p. This potentially leaks sensitive information regarding the Kernel layout in memory. Many of these calls are stale, instead of fixing every call lets hash the address by default before printing. This will of course break some users, forcing code printing needed addresses to be updated.

Code that _really_ needs the address will soon be able to use the new printk specifier %px to print the address.

For what it's worth, usage of unadorned %p can be broken down as follows (thanks to Joe Perches).

$ git grep -E '%p[^A-Za-z0-9]' | cut -f1 -d"/" | sort | uniq -c
   1084 arch
     20 block
     10 crypto
     32 Documentation
   8121 drivers
   1221 fs
    143 include
    101 kernel
     69 lib
    100 mm
   1510 net
     40 samples
      7 scripts
     11 security
    166 sound
    152 tools
      2 virt

Add function ptr_to_id() to map an address to a 32 bit unique identifier. Hash any unadorned usage of specifier %p and any malformed specifiers.

Cc Alexander Potapenko <[email protected]>
Cc Andrey Ryabinin <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Chris Fries <[email protected]>
Cc Daniel Micay <[email protected]>
Cc Dave Weinstein <[email protected]>
Cc David Miller <[email protected]>
Cc Djalal Harouni <[email protected]>
Cc Dmitry Vyukov <[email protected]>
Cc Greg KH <[email protected]>
Cc Ian Campbell <[email protected]>
Cc "Jason A. Donenfeld" <[email protected]>
Cc Joe Perches <[email protected]>
Cc Jordan Glover <[email protected]>
Cc Kees Cook <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Petr Mladek <[email protected]>
Cc Radim Krčmář <[email protected]>
Cc "Roberts, William C" <[email protected]>
Cc Sergey Senozhatsky <[email protected]>
Cc Stephen Rothwell <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Tejun Heo <[email protected]>
Cc "Theodore Ts'o" <[email protected]>
Cc Tycho Andersen <[email protected]>
Cc Will Deacon <[email protected]>

---

 Documentation/printk-formats.txt |   12 ++-
 lib/test_printf.c                |  108 ++++++++++++++++++-----------
 lib/vsprintf.c                   |   81 +++++++++++++++++++--
 3 files changed, 155 insertions(+), 46 deletions(-)
Documentation/printk-formats.txt renamed from Documentation/printk-formats.txt~printk-hash-addresses-printed-with-%p +11 -1
diff -puN Documentation/printk-formats.txt~printk-hash-addresses-printed-with-%p Documentation/printk-formats.txt
@@ -5,7 +5,6 @@ How to get printk format specifiers righ
 :Author: Randy Dunlap <[email protected]>
 :Author: Andrew Murray <[email protected]>
 
-
 Integer types
 =============
 
@@ -45,6 +44,17 @@ return from vsnprintf.
 Raw pointer value SHOULD be printed with %p. The kernel supports
 the following extended format specifiers for pointer types:
 
+Pointer Types
+=============
+
+Pointers printed without a specifier extension (i.e unadorned %p) are
+hashed to give a unique identifier without leaking kernel addresses to user
+space. On 64 bit machines the first 32 bits are zeroed.
+
+::
+
+	%p	abcdef12 or 00000000abcdef12
+
 Symbols/Function Pointers
 =========================
 
lib/test_printf.c renamed from lib/test_printf.c~printk-hash-addresses-printed-with-%p +70 -38

130 lines not on this page · raw message

lib/vsprintf.c renamed from lib/vsprintf.c~printk-hash-addresses-printed-with-%p +74 -7

106 lines not on this page · raw message

_

Patches currently in -mm which might be from [email protected] are