OSDN Git Service

bionic: make NONBLOCK call to getrandom
authorWei Wang <wvw@google.com>
Wed, 23 Nov 2016 18:41:35 +0000 (10:41 -0800)
committerWei Wang <wvw@google.com>
Wed, 23 Nov 2016 23:10:52 +0000 (15:10 -0800)
commitae693ad06cbde6049d962aeea03e285d67caa58b
treecc0da92b41be8c3d7e3545027bfa0dfd53836487
parentd39380cc4d3e9fdd2942da0aaafe939c38b6331e
bionic: make NONBLOCK call to getrandom

By default getrandom() blocks if the entropy pool has not yet been initialized.
This will be an issue when init was first executed in some kernels.

This CL makes a check of getrandom readyness, by adding the GRND_NONBLOCK flag.
In such case, getrandom() does not block returns -1 with errno set to EAGAIN.

Test: on M/S devices
Bug: 33059407
Change-Id: I2a2ba8372a5e1c336852ba2ab77cdaac03c90389
libc/bionic/bionic_arc4random.cpp
libc/bionic/getentropy_linux.c