• Jason A. Donenfeld's avatar
    random: do not throw away excess input to crng_fast_load · 73c7733f
    Jason A. Donenfeld authored
    When crng_fast_load() is called by add_hwgenerator_randomness(), we
    currently will advance to crng_init==1 once we've acquired 64 bytes, and
    then throw away the rest of the buffer. Usually, that is not a problem:
    When add_hwgenerator_randomness() gets called via EFI or DT during
    setup_arch(), there won't be any IRQ randomness. Therefore, the 64 bytes
    passed by EFI exactly matches what is needed to advance to crng_init==1.
    Usually, DT seems to pass 64 bytes as well -- with one notable exception
    being kexec, which hands over 128 bytes of entropy to the kexec'd kernel.
    In that case, we'll advance to crng_init==1 once 64 of those bytes are
    consumed by crng_fast_load(), but won't continue onward feeding in bytes
    to progress to crng_init==2. This commit fixes the issue by feeding
    any leftover bytes into the next phase in add_hwgenerator_randomness().
    
    [linux@dominikbrodowski.net: rewrite commit message]
    Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
    73c7733f
random.c 68.3 KB