diff options
| author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2019-02-21 21:32:24 +0000 |
|---|---|---|
| committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2019-02-21 21:32:24 +0000 |
| commit | df913868066b17c5c87c6169905ebbf8b9a4d0af (patch) | |
| tree | 6af48621815359e6ee7ddba00aefe82015a5202e /compiler-rt/test | |
| parent | d91bb4831b6ca315a9fbde54b7afa6e70e08bec3 (diff) | |
| download | bcm5719-llvm-df913868066b17c5c87c6169905ebbf8b9a4d0af.tar.gz bcm5719-llvm-df913868066b17c5c87c6169905ebbf8b9a4d0af.zip | |
[hwasan,asan] Intercept vfork.
Summary: AArch64 only for now.
Reviewers: vitalybuka, pcc
Subscribers: srhines, kubamracek, mgorny, javed.absar, krytarowski, kristof.beyls, jdoerfert, #sanitizers, llvm-commits, kcc
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D58313
llvm-svn: 354625
Diffstat (limited to 'compiler-rt/test')
| -rw-r--r-- | compiler-rt/test/asan/TestCases/Linux/vfork.cc | 31 | ||||
| -rw-r--r-- | compiler-rt/test/hwasan/TestCases/Linux/vfork.c | 32 |
2 files changed, 63 insertions, 0 deletions
diff --git a/compiler-rt/test/asan/TestCases/Linux/vfork.cc b/compiler-rt/test/asan/TestCases/Linux/vfork.cc new file mode 100644 index 00000000000..6e52fbbaa7f --- /dev/null +++ b/compiler-rt/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-android-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() { + char x[10000]; + __asan_poison_memory_region(x, sizeof(x)); + _exit(0); +} + +__attribute__((noinline, no_sanitize("address"))) void parent() { + char x[10000]; + assert(__asan_address_is_poisoned(x + 5000) == 0); +} + +int main(int argc, char **argv) { + if (vfork()) + parent(); + else + child(); + + return 0; +} diff --git a/compiler-rt/test/hwasan/TestCases/Linux/vfork.c b/compiler-rt/test/hwasan/TestCases/Linux/vfork.c new file mode 100644 index 00000000000..bcdd370d703 --- /dev/null +++ b/compiler-rt/test/hwasan/TestCases/Linux/vfork.c @@ -0,0 +1,32 @@ +// https://github.com/google/sanitizers/issues/925 +// RUN: %clang_hwasan -O0 %s -o %t && %run %t 2>&1 + +// REQUIRES: aarch64-target-arch + +#include <assert.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <unistd.h> +#include <stdio.h> +#include <sanitizer/hwasan_interface.h> + +__attribute__((noinline, no_sanitize("hwaddress"))) void child() { + char x[10000]; + __hwasan_tag_memory(x, 0xAA, sizeof(x)); + _exit(0); +} + +__attribute__((noinline, no_sanitize("hwaddress"))) void parent() { + char x[10000]; + __hwasan_print_shadow(&x, sizeof(x)); + assert(__hwasan_test_shadow(x, sizeof(x)) == -1); +} + +int main(int argc, char **argv) { + if (vfork()) + parent(); + else + child(); + + return 0; +} |

