• Tobin C. Harding's avatar
    printk: hash addresses printed with %p · ad67b74d
    Tobin C. Harding authored
    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
    Signed-off-by: default avatarTobin C. Harding <me@tobin.cc>
test_printf.c 12.5 KB