From bf0ed8e9b8f86509e099f998837314e8fef4dd06 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Fri, 16 Mar 2018 15:34:09 +0000 Subject: [PATCH] Revert "Mmap interceptor new option, Write Exec runtime detector" This reverts r327696 because it is failing on GreenDragon. http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/43605/ http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive/10957/ llvm-svn: 327719 --- .../lib/sanitizer_common/sanitizer_common.h | 2 -- .../sanitizer_common_interceptors.inc | 4 ---- .../sanitizer_common/sanitizer_common_libcdep.cc | 26 ---------------------- .../lib/sanitizer_common/sanitizer_flags.inc | 3 --- .../TestCases/Posix/mmap_write_exec.cpp | 12 ---------- 5 files changed, 47 deletions(-) delete mode 100644 compiler-rt/test/sanitizer_common/TestCases/Posix/mmap_write_exec.cpp diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h index b49e3d8..0a92e77 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h @@ -378,8 +378,6 @@ void ReportErrorSummary(const char *error_type, const AddressInfo &info, void ReportErrorSummary(const char *error_type, const StackTrace *trace, const char *alt_tool_name = nullptr); -void ReportMmapWriteExec(); - // Math #if SANITIZER_WINDOWS && !defined(__clang__) && !defined(__GNUC__) extern "C" { diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index 8c0c3f0..0950f6a 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -6887,8 +6887,6 @@ INTERCEPTOR(SIZE_T, strlcat, char *dst, char *src, SIZE_T size) { INTERCEPTOR(void *, mmap, void *addr, SIZE_T sz, int prot, int flags, int fd, OFF_T off) { void *ctx; - if (common_flags()->detect_write_exec) - ReportMmapWriteExec(); if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED) return (void *)internal_mmap(addr, sz, prot, flags, fd, off); COMMON_INTERCEPTOR_ENTER(ctx, mmap, addr, sz, prot, flags, fd, off); @@ -6903,8 +6901,6 @@ INTERCEPTOR(void *, mmap, void *addr, SIZE_T sz, int prot, int flags, int fd, INTERCEPTOR(void *, mmap64, void *addr, SIZE_T sz, int prot, int flags, int fd, OFF64_T off) { void *ctx; - if (common_flags()->detect_write_exec) - ReportMmapWriteExec(); if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED) return (void *)internal_mmap(addr, sz, prot, flags, fd, off); COMMON_INTERCEPTOR_ENTER(ctx, mmap64, addr, sz, prot, flags, fd, off); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc index 6ba6f62..5cdfbbb 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc @@ -81,32 +81,6 @@ void ReportErrorSummary(const char *error_type, const StackTrace *stack, #endif } -void ReportMmapWriteExec() { - ScopedErrorReportLock l; - - SanitizerCommonDecorator d; - -#if !SANITIZER_GO - BufferedStackTrace stack; - uptr top = 0; - uptr bottom = 0; - GET_CALLER_PC_BP_SP; - (void)sp; - bool fast = common_flags()->fast_unwind_on_fatal; - if (fast) - GetThreadStackTopAndBottom(false, &top, &bottom); - stack.Unwind(kStackTraceMax, pc, bp, nullptr, top, bottom, fast); -#endif - - Printf("%s", d.Warning()); - Report("WARNING: %s: writable-executable page usage\n", SanitizerToolName); - Printf("%s", d.Default()); -#if !SANITIZER_GO - stack.Print(); - ReportErrorSummary("w-and-x-usage", &stack); -#endif -} - static void (*SoftRssLimitExceededCallback)(bool exceeded); void SetSoftRssLimitExceededCallback(void (*Callback)(bool exceeded)) { CHECK_EQ(SoftRssLimitExceededCallback, nullptr); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc b/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc index e607e51..e231a8a 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc @@ -240,6 +240,3 @@ COMMON_FLAG(bool, dump_instruction_bytes, false, COMMON_FLAG(bool, dump_registers, true, "If true, dump values of CPU registers when SEGV happens. Only " "available on OS X for now.") -COMMON_FLAG(bool, detect_write_exec, false, - "If true, triggers warning when writable-executable pages requests " - "are being made") diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/mmap_write_exec.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/mmap_write_exec.cpp deleted file mode 100644 index 2758322..0000000 --- a/compiler-rt/test/sanitizer_common/TestCases/Posix/mmap_write_exec.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// 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 - -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 -} -- 2.7.4