lkml.org 
[lkml]   [2017]   [Oct]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH] printk: hash addresses printed with %p
    From
    Date
    On Wed, 2017-10-11 at 14:48 +1100, Tobin C. Harding wrote:
    > Currently there are many places in the kernel where addresses are being
    > printed using an unadorned %p. Kernel pointers should be printed using
    > %pK allowing some control via the kptr_restrict sysctl. Exposing addresses
    > gives attackers sensitive information about the kernel layout in memory.
    []
    > diff --git a/lib/vsprintf.c b/lib/vsprintf.c
    []
    > @@ -1591,6 +1591,35 @@ char *device_node_string(char *buf, char *end, struct device_node *dn,
    > return widen_string(buf, buf - buf_start, end, spec);
    > }
    >
    > +static long get_random_odd_long(void)
    > +{
    > + long val = 0;
    > +
    > + while((val & 1) == 0) {
    > + val = get_random_long();
    > + }
    > +
    > + return val;
    > +}

    Perhaps

    static long get_random_odd_long(void)
    {
    return get_random_long() | 1L;
    }

    \
     
     \ /
      Last update: 2017-10-11 06:07    [W:4.275 / U:0.512 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site