diff options
author | Josh Gao <jmgao@google.com> | 2016-06-24 13:04:09 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2016-06-28 15:52:59 -0700 |
commit | 250667aaf69bcb701fea099caef6204ad84b1d32 (patch) | |
tree | fe3891a4c1811da6e88975684704581cea05d2dc | |
parent | 36ad0207d67ef395b003dbf75d2c0193d3b8e093 (diff) | |
download | bionic-250667aaf69bcb701fea099caef6204ad84b1d32.tar.gz |
Take the arc4random lock before forking.
Bug: http://b/24675038
Test: stepped through a fork call in gdb
Change-Id: I09d20ff1d103d0c005f2a0cdd9b0a8710ab2392c
-rw-r--r-- | libc/bionic/libc_init_common.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp index 0c9e87b8b..6f5b37999 100644 --- a/libc/bionic/libc_init_common.cpp +++ b/libc/bionic/libc_init_common.cpp @@ -41,13 +41,14 @@ #include <sys/time.h> #include <unistd.h> +#include "private/KernelArgumentBlock.h" +#include "private/WriteProtected.h" #include "private/bionic_auxv.h" #include "private/bionic_globals.h" #include "private/bionic_ssp.h" #include "private/bionic_tls.h" -#include "private/KernelArgumentBlock.h" #include "private/libc_logging.h" -#include "private/WriteProtected.h" +#include "private/thread_private.h" #include "pthread_internal.h" extern "C" abort_msg_t** __abort_message_ptr; @@ -123,6 +124,9 @@ void __libc_init_common(KernelArgumentBlock& args) { pthread_internal_t* main_thread = __get_thread(); __pthread_internal_add(main_thread); + // Register atfork handlers to take and release the arc4random lock. + pthread_atfork(_thread_arc4_lock, _thread_arc4_unlock, _thread_arc4_unlock); + __system_properties_init(); // Requires 'environ'. } |