From: Benjamin Kramer Date: Thu, 20 Apr 2017 20:28:18 +0000 (+0000) Subject: [Support] Make asan poisoning for recyclers more aggressive by also poisoning the... X-Git-Tag: llvmorg-5.0.0-rc1~7141 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9ed1371adb219b791ac446812182e643c1f727dc;p=platform%2Fupstream%2Fllvm.git [Support] Make asan poisoning for recyclers more aggressive by also poisoning the 'next' pointer. llvm-svn: 300882 --- diff --git a/llvm/include/llvm/Support/ArrayRecycler.h b/llvm/include/llvm/Support/ArrayRecycler.h index b4222ca..68696be 100644 --- a/llvm/include/llvm/Support/ArrayRecycler.h +++ b/llvm/include/llvm/Support/ArrayRecycler.h @@ -47,22 +47,21 @@ template class ArrayRecycler { FreeList *Entry = Bucket[Idx]; if (!Entry) return nullptr; + __asan_unpoison_memory_region(Entry, Capacity::get(Idx).getSize()); Bucket[Idx] = Entry->Next; __msan_allocated_memory(Entry, Capacity::get(Idx).getSize()); - __asan_unpoison_memory_region(Entry, Capacity::get(Idx).getSize()); return reinterpret_cast(Entry); } // Add an entry to the free list at Bucket[Idx]. void push(unsigned Idx, T *Ptr) { assert(Ptr && "Cannot recycle NULL pointer"); - __asan_poison_memory_region(Ptr, Capacity::get(Idx).getSize()); - __asan_unpoison_memory_region(Ptr, sizeof(FreeList)); FreeList *Entry = reinterpret_cast(Ptr); if (Idx >= Bucket.size()) Bucket.resize(size_t(Idx) + 1); Entry->Next = Bucket[Idx]; Bucket[Idx] = Entry; + __asan_poison_memory_region(Ptr, Capacity::get(Idx).getSize()); } public: diff --git a/llvm/include/llvm/Support/Recycler.h b/llvm/include/llvm/Support/Recycler.h index dc8b246..53db2e8 100644 --- a/llvm/include/llvm/Support/Recycler.h +++ b/llvm/include/llvm/Support/Recycler.h @@ -42,17 +42,16 @@ class Recycler { FreeNode *pop_val() { auto *Val = FreeList; + __asan_unpoison_memory_region(Val, Size); FreeList = FreeList->Next; __msan_allocated_memory(Val, Size); - __asan_unpoison_memory_region(Val, Size); return Val; } void push(FreeNode *N) { - __asan_poison_memory_region(N, Size); - __asan_unpoison_memory_region(N, sizeof(FreeNode)); N->Next = FreeList; FreeList = N; + __asan_poison_memory_region(N, Size); } public: