From 84b43a132165c8a776aa570bf91809a496166bbe Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Fri, 16 Mar 2018 08:22:18 +0000 Subject: 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@327696 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/sanitizer_common/sanitizer_common_libcdep.cc | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'lib/sanitizer_common/sanitizer_common_libcdep.cc') diff --git a/lib/sanitizer_common/sanitizer_common_libcdep.cc b/lib/sanitizer_common/sanitizer_common_libcdep.cc index 5cdfbbb27..6ba6f62c1 100644 --- a/lib/sanitizer_common/sanitizer_common_libcdep.cc +++ b/lib/sanitizer_common/sanitizer_common_libcdep.cc @@ -81,6 +81,32 @@ 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); -- cgit v1.2.3