summaryrefslogtreecommitdiff
path: root/test/sanitizer_common
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2018-03-16 21:25:09 +0000
committerVitaly Buka <vitalybuka@google.com>2018-03-16 21:25:09 +0000
commitf4140e284d9c82989841f94d9f916a2fc186da3e (patch)
tree07eb28554cb0e632f9b58d51fba9d3761d860f42 /test/sanitizer_common
parent957b9624d6f70e4df40237dc6d41f9b2f8391c95 (diff)
Mmap interceptor new option, Write Exec runtime detector
Summary: Following-up the refactoring of mmap interceptors, adding a new common option to detect PROT_WRITE|PROT_EXEC pages request. Patch by David CARLIER Reviewers: vitalybuka, vsk Reviewed By: vitalybuka Subscribers: krytarowski, #sanitizers Differential Revision: https://reviews.llvm.org/D44194 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@327747 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/sanitizer_common')
-rw-r--r--test/sanitizer_common/TestCases/Linux/mmap_write_exec.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/sanitizer_common/TestCases/Linux/mmap_write_exec.cpp b/test/sanitizer_common/TestCases/Linux/mmap_write_exec.cpp
new file mode 100644
index 000000000..2758322c5
--- /dev/null
+++ b/test/sanitizer_common/TestCases/Linux/mmap_write_exec.cpp
@@ -0,0 +1,12 @@
+// RUN: %clangxx %s -o %t
+// RUN: %env_tool_opts=detect_write_exec=1 %run %t 2>&1 | FileCheck %s
+// ubsan and lsan do not install mmap interceptors
+// UNSUPPORTED: ubsan, lsan
+
+#include <sys/mman.h>
+
+int main(int argc, char **argv) {
+ char *p = (char *)mmap(0, 1024, PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+ // CHECK: WARNING: {{.*}}Sanitizer: writable-executable page usage
+}