From f34324d947b29b5a35a325bbd3901294355b4f39 Mon Sep 17 00:00:00 2001 From: bcook <> Date: Sun, 20 Jul 2014 20:51:13 +0000 Subject: Move more OS-specific functionality to arc4random.h headers. Move and raise(SIGKILL) calls to OS-specific headers. On OpenBSD, move thread_private.h as well to arc4random.h. On Windows, use TerminateProcess on getentropy failure. ok deraadt@ --- src/lib/libcrypto/crypto/arc4random_linux.h | 11 ++++++++++- src/lib/libcrypto/crypto/arc4random_osx.h | 11 ++++++++++- src/lib/libcrypto/crypto/arc4random_solaris.h | 11 ++++++++++- src/lib/libcrypto/crypto/arc4random_win.h | 8 +++++++- 4 files changed, 37 insertions(+), 4 deletions(-) (limited to 'src/lib/libcrypto/crypto') diff --git a/src/lib/libcrypto/crypto/arc4random_linux.h b/src/lib/libcrypto/crypto/arc4random_linux.h index 0da5a4a433..7acba3f78e 100644 --- a/src/lib/libcrypto/crypto/arc4random_linux.h +++ b/src/lib/libcrypto/crypto/arc4random_linux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: arc4random_linux.h,v 1.6 2014/07/19 15:29:25 bcook Exp $ */ +/* $OpenBSD: arc4random_linux.h,v 1.7 2014/07/20 20:51:13 bcook Exp $ */ /* * Copyright (c) 1996, David Mazieres @@ -22,7 +22,10 @@ * Stub functions for portability. */ +#include + #include +#include static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; #define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx) @@ -36,6 +39,12 @@ extern int __register_atfork(void (*)(void), void(*)(void), void (*)(void), void #define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f)) #endif +static inline void +_getentropy_fail(void) +{ + raise(SIGKILL); +} + static volatile sig_atomic_t _rs_forked; static inline void diff --git a/src/lib/libcrypto/crypto/arc4random_osx.h b/src/lib/libcrypto/crypto/arc4random_osx.h index aacbef9aae..c14e044fe2 100644 --- a/src/lib/libcrypto/crypto/arc4random_osx.h +++ b/src/lib/libcrypto/crypto/arc4random_osx.h @@ -1,4 +1,4 @@ -/* $OpenBSD: arc4random_osx.h,v 1.6 2014/07/19 15:29:25 bcook Exp $ */ +/* $OpenBSD: arc4random_osx.h,v 1.7 2014/07/20 20:51:13 bcook Exp $ */ /* * Copyright (c) 1996, David Mazieres @@ -22,7 +22,10 @@ * Stub functions for portability. */ +#include + #include +#include static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; #define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx) @@ -30,6 +33,12 @@ static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; #define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f)) +static inline void +_getentropy_fail(void) +{ + raise(SIGKILL); +} + static volatile sig_atomic_t _rs_forked; static inline void diff --git a/src/lib/libcrypto/crypto/arc4random_solaris.h b/src/lib/libcrypto/crypto/arc4random_solaris.h index 18b1bd54e0..2082a4728f 100644 --- a/src/lib/libcrypto/crypto/arc4random_solaris.h +++ b/src/lib/libcrypto/crypto/arc4random_solaris.h @@ -1,4 +1,4 @@ -/* $OpenBSD: arc4random_solaris.h,v 1.6 2014/07/19 15:29:25 bcook Exp $ */ +/* $OpenBSD: arc4random_solaris.h,v 1.7 2014/07/20 20:51:13 bcook Exp $ */ /* * Copyright (c) 1996, David Mazieres @@ -22,7 +22,10 @@ * Stub functions for portability. */ +#include + #include +#include static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; #define _ARC4_LOCK() pthread_mutex_lock(&arc4random_mtx) @@ -30,6 +33,12 @@ static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; #define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f)) +static inline void +_getentropy_fail(void) +{ + raise(SIGKILL); +} + static volatile sig_atomic_t _rs_forked; static inline void diff --git a/src/lib/libcrypto/crypto/arc4random_win.h b/src/lib/libcrypto/crypto/arc4random_win.h index 1e044de109..b7a5a36013 100644 --- a/src/lib/libcrypto/crypto/arc4random_win.h +++ b/src/lib/libcrypto/crypto/arc4random_win.h @@ -1,4 +1,4 @@ -/* $OpenBSD: arc4random_win.h,v 1.3 2014/07/20 16:59:31 bcook Exp $ */ +/* $OpenBSD: arc4random_win.h,v 1.4 2014/07/20 20:51:13 bcook Exp $ */ /* * Copyright (c) 1996, David Mazieres @@ -42,6 +42,12 @@ static volatile HANDLE arc4random_mtx = NULL; #define _ARC4_UNLOCK() ReleaseMutex(arc4random_mtx) +static inline void +_getentropy_fail(void) +{ + TerminateProcess(GetCurrentProcess(), 0); +} + static inline int _rs_allocate(struct _rs **rsp, struct _rsx **rsxp) { -- cgit v1.2.3-55-g6feb