diff options
author | Vitaly Buka <vitalybuka@google.com> | 2019-08-06 08:41:53 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2019-08-06 08:41:53 +0000 |
commit | b563d22e24d18234bef53d8efe5b53d8c56ddefb (patch) | |
tree | 62508fdc5e8919bbb2a0bd185cc109868192cdb0 /test/sanitizer_common | |
parent | ca7a90c4cdc188dab1e0e6fc5f221433ce84187d (diff) | |
download | compiler-rt-b563d22e24d18234bef53d8efe5b53d8c56ddefb.tar.gz |
[compiler-rt] Implement getrandom interception
Summary:
Straightforward implementation of `getrandom` syscall and libc
hooks.
Test Plan: Local MSAN failures caused by uninstrumented `getrandom`
calls stop failing.
Patch by Andrew Krieger.
Reviewers: eugenis, vitalybuka
Reviewed By: vitalybuka
Subscribers: srhines, kubamracek, dberris, #sanitizers, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D65551
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@367999 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/sanitizer_common')
-rw-r--r-- | test/sanitizer_common/TestCases/Linux/getrandom.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/sanitizer_common/TestCases/Linux/getrandom.cpp b/test/sanitizer_common/TestCases/Linux/getrandom.cpp new file mode 100644 index 000000000..08337f537 --- /dev/null +++ b/test/sanitizer_common/TestCases/Linux/getrandom.cpp @@ -0,0 +1,22 @@ +// RUN: %clangxx -O2 %s -o %t && %run %t +// UNSUPPORTED: android +// + +#include <sys/types.h> + +#if !defined(__GLIBC_PREREQ) +#define __GLIBC_PREREQ(a, b) 0 +#endif + +#if __GLIBC_PREREQ(2, 25) +#include <sys/random.h> +#endif + +int main() { + char buf[16]; + ssize_t n = 1; +#if __GLIBC_PREREQ(2, 25) + n = getrandom(buf, sizeof(buf), 0); +#endif + return (int)(n <= 0); +} |