summaryrefslogtreecommitdiff
path: root/test/asan
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2019-02-27 21:11:50 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2019-02-27 21:11:50 +0000
commit9cde2249660f19f4ffa6d7703cecfdced27f9917 (patch)
tree3a43912617386db72ff90fe311d8119bb793aa11 /test/asan
parent8015adf96f55714e240cec187adfdcffbddbe2b6 (diff)
downloadcompiler-rt-9cde2249660f19f4ffa6d7703cecfdced27f9917.tar.gz
[hwasan, asan] Intercept vfork.
Summary: Intercept vfork on arm, aarch64, i386 and x86_64. Reviewers: pcc, vitalybuka Subscribers: kubamracek, mgorny, javed.absar, krytarowski, kristof.beyls, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58533 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355030 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/asan')
-rw-r--r--test/asan/TestCases/Linux/vfork.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/asan/TestCases/Linux/vfork.cc b/test/asan/TestCases/Linux/vfork.cc
new file mode 100644
index 000000000..31a32dc56
--- /dev/null
+++ b/test/asan/TestCases/Linux/vfork.cc
@@ -0,0 +1,31 @@
+// https://github.com/google/sanitizers/issues/925
+// RUN: %clang_asan -O0 %s -o %t && %run %t 2>&1
+
+// REQUIRES: aarch64-target-arch || x86_64-target-arch || i386-target-arch || arm-target-arch
+
+#include <assert.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sanitizer/asan_interface.h>
+
+__attribute__((noinline, no_sanitize("address"))) void child() {
+ alignas(8) char x[100000];
+ __asan_poison_memory_region(x, sizeof(x));
+ _exit(0);
+}
+
+__attribute__((noinline, no_sanitize("address"))) void parent() {
+ alignas(8) char x[100000];
+ assert(__asan_address_is_poisoned(x + 5000) == 0);
+}
+
+int main(int argc, char **argv) {
+ if (vfork())
+ parent();
+ else
+ child();
+
+ return 0;
+}