diff options
author | Kostya Serebryany <kcc@google.com> | 2016-02-09 23:46:43 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2016-02-09 23:46:43 +0000 |
commit | 476eaf8d989cadfc10169a678de3f6b92aff65a0 (patch) | |
tree | 2d5fa3c7046cb2a63a6e692eb2a10533c896c52d /test | |
parent | 7895f5b615d2b9f24ad6bcc05f1e2d63ba753c4f (diff) |
[asan] update the scariness score: tweak a few weights and add tests
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@260327 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/asan/TestCases/Linux/scariness_score_test.cc | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/test/asan/TestCases/Linux/scariness_score_test.cc b/test/asan/TestCases/Linux/scariness_score_test.cc index 65906e8db..77d58b70d 100644 --- a/test/asan/TestCases/Linux/scariness_score_test.cc +++ b/test/asan/TestCases/Linux/scariness_score_test.cc @@ -2,6 +2,8 @@ // RUN: %clangxx_asan -O0 %s -o %t // RUN: export %env_asan_opts=detect_stack_use_after_return=1:handle_abort=1:print_scariness=1 +// Make sure the stack is limited (may not be the default under GNU make) +// RUN: ulimit -s 4096 // RUN: not %run %t 1 2>&1 | FileCheck %s --check-prefix=CHECK1 // RUN: not %run %t 2 2>&1 | FileCheck %s --check-prefix=CHECK2 // RUN: not %run %t 3 2>&1 | FileCheck %s --check-prefix=CHECK3 @@ -19,8 +21,7 @@ // RUN: not %run %t 15 2>&1 | FileCheck %s --check-prefix=CHECK15 // RUN: not %run %t 16 2>&1 | FileCheck %s --check-prefix=CHECK16 // RUN: not %run %t 17 2>&1 | FileCheck %s --check-prefix=CHECK17 -// Stack overflow may not trigger under GNU make. -// DISABLED: not %run %t 18 2>&1 | FileCheck %s --check-prefix=CHECK18 +// RUN: not %run %t 18 2>&1 | FileCheck %s --check-prefix=CHECK18 // RUN: not %run %t 19 2>&1 | FileCheck %s --check-prefix=CHECK19 // RUN: not %run %t 20 2>&1 | FileCheck %s --check-prefix=CHECK20 // RUN: not %run %t 21 2>&1 | FileCheck %s --check-prefix=CHECK21 @@ -29,12 +30,16 @@ // RUN: not %run %t 24 2>&1 | FileCheck %s --check-prefix=CHECK24 // RUN: not %run %t 25 2>&1 | FileCheck %s --check-prefix=CHECK25 // RUN: not %run %t 26 2>&1 | FileCheck %s --check-prefix=CHECK26 +// RUN: not %run %t 27 2>&1 | FileCheck %s --check-prefix=CHECK27 // Parts of the test are too platform-specific: // REQUIRES: x86_64-supported-target +// REQUIRES: shell #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <sanitizer/asan_interface.h> + enum ReadOrWrite { Read = 0, Write = 1 }; struct S32 { @@ -114,6 +119,13 @@ void StackOverflow(int Idx) { StackOverflow(Idx - 1); } +void UseAfterPoison() { + int buf[100]; + __asan_poison_memory_region(buf, sizeof(buf)); + static volatile int sink; + sink = buf[42]; +} + int main(int argc, char **argv) { char arr[100]; static volatile int zero = 0; @@ -148,6 +160,7 @@ int main(int argc, char **argv) { case 24: delete (new int[10]); break; case 25: free((char*)malloc(100) + 10); break; case 26: memcpy(arr, arr+10, 20); break; + case 27: UseAfterPoison(); break; // CHECK1: SCARINESS: 12 (1-byte-read-heap-buffer-overflow) // CHECK2: SCARINESS: 17 (4-byte-read-heap-buffer-overflow) // CHECK3: SCARINESS: 33 (2-byte-write-heap-buffer-overflow) @@ -165,14 +178,15 @@ int main(int argc, char **argv) { // CHECK15: SCARINESS: 31 (1-byte-write-global-buffer-overflow) // CHECK16: SCARINESS: 36 (multi-byte-read-global-buffer-overflow-far-from-bounds) // CHECK17: SCARINESS: 42 (double-free) - // CHECK18: SCARINESS: 15 (stack-overflow) + // CHECK18: SCARINESS: 10 (stack-overflow) // CHECK19: SCARINESS: 10 (null-deref) // CHECK20: SCARINESS: 30 (wild-addr-write) // CHECK21: SCARINESS: 20 (wild-addr-read) // CHECK22: SCARINESS: 10 (signal) // CHECK23: SCARINESS: 60 (wild-jump) // CHECK24: SCARINESS: 10 (alloc-dealloc-mismatch) - // CHECK25: SCARINESS: 10 (bad-free) + // CHECK25: SCARINESS: 40 (bad-free) // CHECK26: SCARINESS: 10 (memcpy-param-overlap) + // CHECK27: SCARINESS: 27 (4-byte-read-use-after-poison) } } |