Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2494)

Unified Diff: syzygy/agent/asan/heap_managers/block_heap_manager.cc

Issue 2527533003: Make SyzyAsan support the allocation > 1GB (Closed)
Patch Set: Add a maximum allocation size check. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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) {
« no previous file with comments | « syzygy/agent/asan/error_info_unittest.cc ('k') | syzygy/agent/asan/heap_managers/block_heap_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698