Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

random_seed.c: prefer getrandom() / /dev/{,u}random over arc4random() #832

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Sep 15, 2023

  1. random_seed.c: prefer getrandom() / /dev/{,u}random over arc4random()

    arc4random(3) is problematic to use during early boot, as it (as implemented
    by glibc or libbsd) uses getrandom(2) without the GRND_NONBLOCK flag,
    causing it to block until the kernel entropy pool is initialized, which may
    take a very long time.
    
    One example of this is cryptsetup(8), which may be used for bringing up a
    LUKS encrypted root filesystem during early boot.
    
    So instead prefer getrandom(.., GRND_NONBLOCK) (which will fail before the
    pool is initialized) and /dev/urandom (which will succeed, but cause the
    kernel to print a warning about access before the pool is initialized)
    before falling back to arc4random().
    
    Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
    jacmet committed Sep 15, 2023
    Configuration menu
    Copy the full SHA
    572ab9b View commit details
    Browse the repository at this point in the history