• David Keisar Schmidt's avatar
    mm/slab: Replace invocation of weak PRNG · f7e466e9
    David Keisar Schmidt authored
    The Slab allocator randomization uses the prandom_u32
    PRNG. That was added to prevent attackers to obtain information on the heap
    state, by randomizing the freelists state.
    
    However, this PRNG turned out to be weak, as noted in commit c51f8f88
    
    
    To fix it, we have changed the invocation of prandom_u32_state to get_random_u32
    to ensure the PRNG is strong. Since a modulo operation is applied right after that,
    we used get_random_u32_below, to achieve uniformity.
    
    In addition, we changed the freelist_init_state union to struct,
    since the rnd_state inside which is used to store the state of prandom_u32,
    is not needed anymore, since get_random_u32 maintains its own state.
    Signed-off-by: default avatarDavid Keisar Schmidt <david.keisarschm@mail.huji.ac.il>
    Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
    f7e466e9
slab.c 102 KB