Skip to content

Commit 431bca2

Browse files
geertupmladek
authored andcommitted
lib/vsprintf: Hash printed address for netdev bits fallback
The handler for "%pN" falls back to printing the raw pointer value when using a different format than the (sole supported) special format "%pNF", potentially leaking sensitive information regarding the kernel layout in memory. Avoid this leak by printing the hashed address instead. Note that there are no in-tree users of the fallback. Fixes: ad67b74 ("printk: hash addresses printed with %p") Link: http://lkml.kernel.org/r/20181011084249.4520-4-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 ec12bc2 commit 431bca2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/vsprintf.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,8 @@ char *restricted_pointer(char *buf, char *end, const void *ptr,
15101510
}
15111511

15121512
static noinline_for_stack
1513-
char *netdev_bits(char *buf, char *end, const void *addr, const char *fmt)
1513+
char *netdev_bits(char *buf, char *end, const void *addr,
1514+
struct printf_spec spec, const char *fmt)
15141515
{
15151516
unsigned long long num;
15161517
int size;
@@ -1521,9 +1522,7 @@ char *netdev_bits(char *buf, char *end, const void *addr, const char *fmt)
15211522
size = sizeof(netdev_features_t);
15221523
break;
15231524
default:
1524-
num = (unsigned long)addr;
1525-
size = sizeof(unsigned long);
1526-
break;
1525+
return ptr_to_id(buf, end, addr, spec);
15271526
}
15281527

15291528
return special_hex_number(buf, end, num, size);
@@ -1945,7 +1944,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
19451944
break;
19461945
return restricted_pointer(buf, end, ptr, spec);
19471946
case 'N':
1948-
return netdev_bits(buf, end, ptr, fmt);
1947+
return netdev_bits(buf, end, ptr, spec, fmt);
19491948
case 'a':
19501949
return address_val(buf, end, ptr, fmt);
19511950
case 'd':

0 commit comments

Comments
 (0)