• Jason A. Donenfeld's avatar
    um: seed rng using host OS rng · 0b9ba613
    Jason A. Donenfeld authored
    UML generally does not provide access to special CPU instructions like
    RDRAND, and execution tends to be rather deterministic, with no real
    hardware interrupts, making good randomness really very hard, if not
    all together impossible. Not only is this a security eyebrow raiser, but
    it's also quite annoying when trying to do various pieces of UML-based
    automation that takes a long time to boot, if ever.
    
    Fix this by trivially calling getrandom() in the host and using that
    seed as "bootloader randomness", which initializes the rng immediately
    at UML boot.
    
    The old behavior can be restored the same way as on any other arch, by
    way of CONFIG_TRUST_BOOTLOADER_RANDOMNESS=n or
    random.trust_bootloader=0. So seen from that perspective, this just
    makes UML act like other archs, which is positive in its own right.
    
    Additionally, wire up arch_get_random_{int,long}() in the same way, so
    that reseeds can also make use of the host RNG, controllable by
    CONFIG_TRUST_CPU_RANDOMNESS and random.trust_cpu, per usual.
    
    Cc: stable@vger.kernel.org
    Acked-by: default avatarJohannes Berg <johannes@sipsolutions.net>
    Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
    Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
    0b9ba613
um_arch.c 11.8 KB