[llvm-commits] [compiler-rt] r163308 - in /compiler-rt/trunk/lib: asan/asan_rtl.cc asan/asan_thread.cc asan/lit_tests/deep_stack_uaf.cc sanitizer_common/sanitizer_stacktrace.h
Kostya Serebryany
kcc at google.com
Thu Sep 6 03:57:03 PDT 2012
Author: kcc
Date: Thu Sep 6 05:57:03 2012
New Revision: 163308
URL: http://llvm.org/viewvc/llvm-project?rev=163308&view=rev
Log:
[asan] increase max stack size to 256 (+test)
Added:
compiler-rt/trunk/lib/asan/lit_tests/deep_stack_uaf.cc
Modified:
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/asan/asan_thread.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=163308&r1=163307&r2=163308&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Thu Sep 6 05:57:03 2012
@@ -62,7 +62,7 @@
namespace __asan {
// -------------------------- Flags ------------------------- {{{1
-static const int kMallocContextSize = 64;
+static const int kDeafultMallocContextSize = 30;
static Flags asan_flags;
@@ -82,7 +82,7 @@
ParseFlag(str, &f->report_globals, "report_globals");
ParseFlag(str, &f->check_initialization_order, "initialization_order");
ParseFlag(str, &f->malloc_context_size, "malloc_context_size");
- CHECK(f->malloc_context_size <= kMallocContextSize);
+ CHECK(f->malloc_context_size <= kStackTraceMax);
ParseFlag(str, &f->replace_str, "replace_str");
ParseFlag(str, &f->replace_intrin, "replace_intrin");
@@ -121,7 +121,7 @@
f->debug = false;
f->report_globals = 1;
f->check_initialization_order = true;
- f->malloc_context_size = kMallocContextSize;
+ f->malloc_context_size = kDeafultMallocContextSize;
f->replace_str = true;
f->replace_intrin = true;
f->replace_cfallocator = true;
Modified: compiler-rt/trunk/lib/asan/asan_thread.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_thread.cc?rev=163308&r1=163307&r2=163308&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_thread.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_thread.cc Thu Sep 6 05:57:03 2012
@@ -26,9 +26,6 @@
malloc_storage_(x),
stats_(x) { }
-static AsanLock mu_for_thread_summary(LINKER_INITIALIZED);
-static LowLevelAllocator allocator_for_thread_summary;
-
AsanThread *AsanThread::Create(u32 parent_tid, thread_callback_t start_routine,
void *arg, StackTrace *stack) {
uptr size = RoundUpTo(sizeof(AsanThread), kPageSize);
@@ -36,14 +33,10 @@
thread->start_routine_ = start_routine;
thread->arg_ = arg;
- const uptr kSummaryAllocSize = 1024;
+ const uptr kSummaryAllocSize = kPageSize;
CHECK_LE(sizeof(AsanThreadSummary), kSummaryAllocSize);
- AsanThreadSummary *summary;
- {
- ScopedLock lock(&mu_for_thread_summary);
- summary = (AsanThreadSummary*)
- allocator_for_thread_summary.Allocate(kSummaryAllocSize);
- }
+ AsanThreadSummary *summary =
+ (AsanThreadSummary*)MmapOrDie(kPageSize, "AsanThreadSummary");
summary->Init(parent_tid, stack);
summary->set_thread(thread);
thread->set_summary(summary);
Added: compiler-rt/trunk/lib/asan/lit_tests/deep_stack_uaf.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/deep_stack_uaf.cc?rev=163308&view=auto
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/deep_stack_uaf.cc (added)
+++ compiler-rt/trunk/lib/asan/lit_tests/deep_stack_uaf.cc Thu Sep 6 05:57:03 2012
@@ -0,0 +1,36 @@
+// Check that we can store lots of stack frames if asked to.
+
+// RUN: %clangxx_asan -m64 -O0 %s -o %t 2>&1
+// RUN: ASAN_OPTIONS=malloc_context_size=120:redzone=512 %t 2>&1 | \
+// RUN: %symbolize | FileCheck %s
+
+// RUN: %clangxx_asan -m32 -O0 %s -o %t 2>&1
+// RUN: ASAN_OPTIONS=malloc_context_size=120:redzone=512 %t 2>&1 | \
+// RUN: %symbolize | FileCheck %s
+#include <stdlib.h>
+#include <stdio.h>
+
+template <int depth>
+struct DeepFree {
+ static void free(char *x) {
+ DeepFree<depth - 1>::free(x);
+ }
+};
+
+template<>
+struct DeepFree<0> {
+ static void free(char *x) {
+ ::free(x);
+ }
+};
+
+int main() {
+ char *x = new char[10];
+ // deep_free(x);
+ DeepFree<200>::free(x);
+ return x[5];
+ // CHECK: {{.*ERROR: AddressSanitizer heap-use-after-free on address}}
+ // CHECK: DeepFree<36>
+ // CHECK: DeepFree<98>
+ // CHECK: DeepFree<115>
+}
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h?rev=163308&r1=163307&r2=163308&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.h Thu Sep 6 05:57:03 2012
@@ -17,7 +17,7 @@
namespace __sanitizer {
-static const uptr kStackTraceMax = 64;
+static const uptr kStackTraceMax = 256;
struct StackTrace {
typedef bool (*SymbolizeCallback)(const void *pc, char *out_buffer,
More information about the llvm-commits
mailing list