diff options
Diffstat (limited to 'test/asan/TestCases/Linux')
-rw-r--r-- | test/asan/TestCases/Linux/asan-asm-stacktrace-test.cc | 33 | ||||
-rw-r--r-- | test/asan/TestCases/Linux/bzero.cc | 15 | ||||
-rw-r--r-- | test/asan/TestCases/Linux/swapcontext_annotation.cc | 3 | ||||
-rw-r--r-- | test/asan/TestCases/Linux/swapcontext_test.cc | 3 | ||||
-rw-r--r-- | test/asan/TestCases/Linux/unpoison_tls.cc | 2 | ||||
-rw-r--r-- | test/asan/TestCases/Linux/vfork.cc | 31 |
6 files changed, 51 insertions, 36 deletions
diff --git a/test/asan/TestCases/Linux/asan-asm-stacktrace-test.cc b/test/asan/TestCases/Linux/asan-asm-stacktrace-test.cc deleted file mode 100644 index acbe94726..000000000 --- a/test/asan/TestCases/Linux/asan-asm-stacktrace-test.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Check that a stack unwinding algorithm works corretly even with the assembly -// instrumentation. - -// REQUIRES: x86_64-target-arch, shadow-scale-3 -// RUN: %clangxx_asan -g -O1 %s -fno-inline-functions -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -mllvm -asan-instrument-assembly -o %t && not %run %t 2>&1 | FileCheck %s -// RUN: %clangxx_asan -g -O1 %s -fno-inline-functions -fomit-frame-pointer -momit-leaf-frame-pointer -mllvm -asan-instrument-assembly -o %t && not %run %t 2>&1 | FileCheck %s -// RUN: %clangxx_asan -g0 -O1 %s -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-exceptions -fno-inline-functions -fomit-frame-pointer -momit-leaf-frame-pointer -mllvm -asan-instrument-assembly -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-nounwind - -#include <cstddef> - -// CHECK: READ of size 4 -// CHECK-NEXT: {{#0 0x[0-9a-fA-F]+ in foo}} -// CHECK-NEXT: {{#1 0x[0-9a-fA-F]+ in main}} - -// CHECK-nounwind: READ of size 4 -// CHECK-nounwind-NEXT: {{#0 0x[0-9a-fA-F]+ in foo}} - -__attribute__((noinline)) int foo(size_t n, int *buffer) { - int r; - __asm__("movl (%[buffer], %[n], 4), %[r] \n\t" - : [r] "=r"(r) - : [buffer] "r"(buffer), [n] "r"(n) - : "memory"); - return r; -} - -int main() { - const size_t n = 16; - int *buffer = new int[n]; - foo(n, buffer); - delete[] buffer; - return 0; -} diff --git a/test/asan/TestCases/Linux/bzero.cc b/test/asan/TestCases/Linux/bzero.cc new file mode 100644 index 000000000..430edb744 --- /dev/null +++ b/test/asan/TestCases/Linux/bzero.cc @@ -0,0 +1,15 @@ +// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s + +// REQUIRES: !android + +#include <assert.h> +#include <strings.h> + +int main(int argc, char *argv[]) { + char buf[100]; + // *& to suppress bzero-to-memset optimization. + (*&bzero)(buf, sizeof(buf) + 1); + // CHECK: AddressSanitizer: stack-buffer-overflow + // CHECK-NEXT: WRITE of size 101 at + return 0; +} diff --git a/test/asan/TestCases/Linux/swapcontext_annotation.cc b/test/asan/TestCases/Linux/swapcontext_annotation.cc index 3bfda7353..5eae27a32 100644 --- a/test/asan/TestCases/Linux/swapcontext_annotation.cc +++ b/test/asan/TestCases/Linux/swapcontext_annotation.cc @@ -12,7 +12,8 @@ // // This test is too subtle to try on non-x86 arch for now. -// REQUIRES: x86-target-arch +// Android does not support swapcontext. +// REQUIRES: x86-target-arch && !android #include <pthread.h> #include <setjmp.h> diff --git a/test/asan/TestCases/Linux/swapcontext_test.cc b/test/asan/TestCases/Linux/swapcontext_test.cc index 210a667d0..2660ffe3b 100644 --- a/test/asan/TestCases/Linux/swapcontext_test.cc +++ b/test/asan/TestCases/Linux/swapcontext_test.cc @@ -6,7 +6,8 @@ // RUN: %clangxx_asan -O3 %s -o %t && %run %t 2>&1 | FileCheck %s // // This test is too sublte to try on non-x86 arch for now. -// REQUIRES: x86-target-arch +// Android does not support swapcontext. +// REQUIRES: x86-target-arch && !android #include <stdio.h> #include <ucontext.h> diff --git a/test/asan/TestCases/Linux/unpoison_tls.cc b/test/asan/TestCases/Linux/unpoison_tls.cc index 19ebec467..e22345342 100644 --- a/test/asan/TestCases/Linux/unpoison_tls.cc +++ b/test/asan/TestCases/Linux/unpoison_tls.cc @@ -1,5 +1,5 @@ // Test that TLS is unpoisoned on thread death. -// REQUIRES: x86-target-arch +// REQUIRES: x86-target-arch && !android // RUN: %clangxx_asan -O1 %s -pthread -o %t && %run %t 2>&1 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; +} |