forked from OSchip/llvm-project
[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
This commit is contained in:
parent
b9eb34e100
commit
63c36bbe5e
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue