diff options
author | David Carlier <devnexen@gmail.com> | 2018-12-28 16:04:28 +0000 |
---|---|---|
committer | David Carlier <devnexen@gmail.com> | 2018-12-28 16:04:28 +0000 |
commit | e2e466f82b24778a4b3caea3d914af843575006f (patch) | |
tree | d2002a970a07bbcdc0e7ecc46db981baabfc40f0 /lib/sanitizer_common/sanitizer_common_interceptors.inc | |
parent | 9341ca95a9a83f717c3ed57fb22c1acd52a2814e (diff) | |
download | compiler-rt-e2e466f82b24778a4b3caea3d914af843575006f.tar.gz |
[Sanitizer] Intercept arc4random_buf / arc4random_addrandom on FreeBSD/NetBSD
- Disabled on purpose on Android and Darwin platform (for now).
- Darwin supports it, would need interception in its specific code before enabling it.
- Linux does not support it but only via third party library.
- Android supports it via bionic however it is known to have issue with older versions of the implementations. Can be enabled by an Android committer later on if necessary once there is more 'certainity'/been more tested.
Reviewers: krytarowski, vitalybuka
Reviewed By: krytarowski
Differential Revision: https://reviews.llvm.org/D56125
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@350123 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_common_interceptors.inc')
-rw-r--r-- | lib/sanitizer_common/sanitizer_common_interceptors.inc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc index c80498a1b..35e639cd2 100644 --- a/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -9084,6 +9084,31 @@ INTERCEPTOR(void *, getfsfile, const char *file) { #else #define INIT_GETFSENT #endif + +#if SANITIZER_INTERCEPT_ARC4RANDOM +INTERCEPTOR(void, arc4random_buf, void *buf, SIZE_T len) { + void *ctx; + COMMON_INTERCEPTOR_ENTER(ctx, arc4random_buf, buf, len); + REAL(arc4random_buf)(buf, len); + if (buf && len) + COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, len); +} + +INTERCEPTOR(void, arc4random_addrandom, u8 *dat, int datlen) { + void *ctx; + COMMON_INTERCEPTOR_ENTER(ctx, arc4random_addrandom, dat, datlen); + if (dat && datlen) + COMMON_INTERCEPTOR_READ_RANGE(ctx, dat, datlen); + REAL(arc4random_addrandom)(dat, datlen); +} + +#define INIT_ARC4RANDOM \ + COMMON_INTERCEPT_FUNCTION(arc4random_buf); \ + COMMON_INTERCEPT_FUNCTION(arc4random_addrandom); +#else +#define INIT_ARC4RANDOM +#endif + static void InitializeCommonInterceptors() { static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1]; interceptor_metadata_map = @@ -9365,6 +9390,7 @@ static void InitializeCommonInterceptors() { INIT_VIS; INIT_CDB; INIT_GETFSENT; + INIT_ARC4RANDOM; INIT___PRINTF_CHK; } |