diff options
author | Kostya Serebryany <kcc@google.com> | 2013-01-18 11:30:36 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2013-01-18 11:30:36 +0000 |
commit | 63c36bbe5e0ae8d64df8c2a3be6c0b072febdc9a (patch) | |
tree | f1b4df0cd87bb6b3ce10c002d46be0aea8309aab | |
parent | b9eb34e10050c6362b6b804abf02e703dfd1c23b (diff) | |
download | bcm5719-llvm-63c36bbe5e0ae8d64df8c2a3be6c0b072febdc9a.tar.gz bcm5719-llvm-63c36bbe5e0ae8d64df8c2a3be6c0b072febdc9a.zip |
[asan] fix two off-by-one errors that seem to affect only PowerPC because only there the stack top may be equal to the address space top. Noted by Andreas Schwab in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55975#c11 . Also make swapcontext interceptor a bit more robust
llvm-svn: 172807
-rw-r--r-- | compiler-rt/lib/asan/asan_interceptors.cc | 2 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_poisoning.cc | 2 | ||||
-rw-r--r-- | compiler-rt/lib/asan/asan_thread.cc | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/compiler-rt/lib/asan/asan_interceptors.cc b/compiler-rt/lib/asan/asan_interceptors.cc index 75e5371952c..30d44e523f1 100644 --- a/compiler-rt/lib/asan/asan_interceptors.cc +++ b/compiler-rt/lib/asan/asan_interceptors.cc @@ -140,7 +140,7 @@ static void ClearShadowMemoryForContextStack(uptr stack, uptr ssize) { ssize += stack - bottom; ssize = RoundUpTo(ssize, PageSize); static const uptr kMaxSaneContextStackSize = 1 << 22; // 4 Mb - if (ssize <= kMaxSaneContextStackSize) { + if (ssize && ssize <= kMaxSaneContextStackSize) { PoisonShadow(bottom, ssize, 0); } } diff --git a/compiler-rt/lib/asan/asan_poisoning.cc b/compiler-rt/lib/asan/asan_poisoning.cc index 295db5a6683..dc574924356 100644 --- a/compiler-rt/lib/asan/asan_poisoning.cc +++ b/compiler-rt/lib/asan/asan_poisoning.cc @@ -25,7 +25,7 @@ void PoisonShadow(uptr addr, uptr size, u8 value) { CHECK(AddrIsAlignedByGranularity(addr)); CHECK(AddrIsAlignedByGranularity(addr + size)); uptr shadow_beg = MemToShadow(addr); - uptr shadow_end = MemToShadow(addr + size); + uptr shadow_end = MemToShadow(addr + size - SHADOW_GRANULARITY) + 1; CHECK(REAL(memset) != 0); REAL(memset)((void*)shadow_beg, value, shadow_end - shadow_beg); } diff --git a/compiler-rt/lib/asan/asan_thread.cc b/compiler-rt/lib/asan/asan_thread.cc index a77e435793d..778e91932ed 100644 --- a/compiler-rt/lib/asan/asan_thread.cc +++ b/compiler-rt/lib/asan/asan_thread.cc @@ -74,7 +74,7 @@ void AsanThread::Destroy() { void AsanThread::Init() { SetThreadStackTopAndBottom(); CHECK(AddrIsInMem(stack_bottom_)); - CHECK(AddrIsInMem(stack_top_)); + CHECK(AddrIsInMem(stack_top_ - 1)); ClearShadowForThreadStack(); if (flags()->verbosity >= 1) { int local = 0; |