Chromium Code Reviews| Index: syzygy/agent/asan/heap_managers/block_heap_manager.cc |
| diff --git a/syzygy/agent/asan/heap_managers/block_heap_manager.cc b/syzygy/agent/asan/heap_managers/block_heap_manager.cc |
| index 515ab9e7db07e0951237bb45c2d79bec78aabe59..c24cbfb5cab3472f86a42f9e59fd28e12421be19 100644 |
| --- a/syzygy/agent/asan/heap_managers/block_heap_manager.cc |
| +++ b/syzygy/agent/asan/heap_managers/block_heap_manager.cc |
| @@ -45,6 +45,11 @@ using heaps::ZebraBlockHeap; |
| // TODO(georgesak): allow this to be changed through the parameters. |
| enum : uint32_t { kOverbudgetSizePercentage = 20 }; |
| +// The maximum allocation size that we can handle in SyzyAsan, this is |
| +// constrained by the number of bits used to store the block size in the block |
| +// header structure. |
| +const size_t kMaxAllocSize = 0x8000000; |
|
chrisha
2016/11/23 19:37:17
This should be part of block.h, and tied to a #def
Sébastien Marchand
2016/11/23 22:36:01
I've tried this but it doesn't seem to work, doing
chrisha
2016/11/24 17:23:22
Acknowledged.
|
| + |
| // Return the position of the most significant bit in a 32 bit unsigned value. |
| size_t GetMSBIndex(size_t n) { |
| // Algorithm taken from |
| @@ -176,6 +181,11 @@ void* BlockHeapManager::Allocate(HeapId heap_id, uint32_t bytes) { |
| DCHECK(initialized_); |
| DCHECK(IsValidHeapId(heap_id, false)); |
| + // Prevent from trying to allocate a memory block bigger than what we can |
| + // represent in the block header. |
| + if (bytes > kMaxAllocSize) |
| + return nullptr; |
|
chrisha
2016/11/23 19:37:17
I'd just push this through to the underlying heap
Sébastien Marchand
2016/11/23 22:36:01
I think that this should live in block.cc::BlockPl
|
| + |
| // Some allocations can pass through without instrumentation. |
| if (parameters_.allocation_guard_rate < 1.0 && |
| base::RandDouble() >= parameters_.allocation_guard_rate) { |