[llvm] r300882 - [Support] Make asan poisoning for recyclers more aggressive by also poisoning the 'next' pointer.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 20 13:28:19 PDT 2017
Author: d0k
Date: Thu Apr 20 15:28:18 2017
New Revision: 300882
URL: http://llvm.org/viewvc/llvm-project?rev=300882&view=rev
Log:
[Support] Make asan poisoning for recyclers more aggressive by also poisoning the 'next' pointer.
Modified:
llvm/trunk/include/llvm/Support/ArrayRecycler.h
llvm/trunk/include/llvm/Support/Recycler.h
Modified: llvm/trunk/include/llvm/Support/ArrayRecycler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ArrayRecycler.h?rev=300882&r1=300881&r2=300882&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ArrayRecycler.h (original)
+++ llvm/trunk/include/llvm/Support/ArrayRecycler.h Thu Apr 20 15:28:18 2017
@@ -47,22 +47,21 @@ template <class T, size_t Align = aligno
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<T*>(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<FreeList*>(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:
Modified: llvm/trunk/include/llvm/Support/Recycler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Recycler.h?rev=300882&r1=300881&r2=300882&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Recycler.h (original)
+++ llvm/trunk/include/llvm/Support/Recycler.h Thu Apr 20 15:28:18 2017
@@ -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:
More information about the llvm-commits
mailing list