diff options
| author | Vitaly Buka <vitalybuka@google.com> | 2018-03-21 21:25:07 +0000 |
|---|---|---|
| committer | Vitaly Buka <vitalybuka@google.com> | 2018-03-21 21:25:07 +0000 |
| commit | 8980449bb61271fad733e15183946b3def484f3c (patch) | |
| tree | a908f28bec7cdacef6772145eb03b883400045f2 /compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc | |
| parent | 1442a5dd3ad91e0a57bf8677a58ca87a6bf54041 (diff) | |
| download | bcm5719-llvm-8980449bb61271fad733e15183946b3def484f3c.tar.gz bcm5719-llvm-8980449bb61271fad733e15183946b3def484f3c.zip | |
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
llvm-svn: 328151
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc')
| -rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc index 5cdfbbb275f..7f07bcfd031 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc @@ -81,6 +81,32 @@ void ReportErrorSummary(const char *error_type, const StackTrace *stack, #endif } +void ReportMmapWriteExec() { +#if !SANITIZER_GO && !SANITIZER_ANDROID + ScopedErrorReportLock l; + SanitizerCommonDecorator d; + + InternalScopedBuffer<BufferedStackTrace> stack_buffer(1); + BufferedStackTrace *stack = stack_buffer.data(); + stack->Reset(); + 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); + + Printf("%s", d.Warning()); + Report("WARNING: %s: writable-executable page usage\n", SanitizerToolName); + Printf("%s", d.Default()); + + stack->Print(); + ReportErrorSummary("w-and-x-usage", stack); +#endif +} + static void (*SoftRssLimitExceededCallback)(bool exceeded); void SetSoftRssLimitExceededCallback(void (*Callback)(bool exceeded)) { CHECK_EQ(SoftRssLimitExceededCallback, nullptr); |

