kernel/slab: Add checks to object_cache_alloc for 0xdeadbeef.
We should always find it if PARANOID_KERNEL_FREE is enabled and the object size is at least 2 pointers.
This commit is contained in:
@@ -159,6 +159,7 @@ ObjectCache::InitSlab(slab* slab, void* pages, size_t byteCount, uint32 flags)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fill_freed_block(data, object_size);
|
||||
slab->free.Push(object_to_link(data, object_size));
|
||||
|
||||
ADD_PARANOIA_CHECK(PARANOIA_SUSPICIOUS, slab,
|
||||
|
||||
@@ -1240,14 +1240,11 @@ object_cache_set_minimum_reserve(object_cache* cache, size_t objectCount)
|
||||
void*
|
||||
object_cache_alloc(object_cache* cache, uint32 flags)
|
||||
{
|
||||
if (!(cache->flags & CACHE_NO_DEPOT)) {
|
||||
void* object = object_depot_obtain(&cache->depot);
|
||||
if (object) {
|
||||
add_alloc_tracing_entry(cache, flags, object);
|
||||
return fill_allocated_block(object, cache->object_size);
|
||||
}
|
||||
}
|
||||
void* object = NULL;
|
||||
if ((cache->flags & CACHE_NO_DEPOT) == 0)
|
||||
object = object_depot_obtain(&cache->depot);
|
||||
|
||||
if (object == NULL) {
|
||||
MutexLocker locker(cache->lock);
|
||||
slab* source = NULL;
|
||||
|
||||
@@ -1291,8 +1288,15 @@ object_cache_alloc(object_cache* cache, uint32 flags)
|
||||
cache->full.Add(source);
|
||||
}
|
||||
|
||||
void* object = link_to_object(link, cache->object_size);
|
||||
object = link_to_object(link, cache->object_size);
|
||||
locker.Unlock();
|
||||
}
|
||||
|
||||
#if PARANOID_KERNEL_FREE
|
||||
if (cache->object_size >= (sizeof(void*) * 2)) {
|
||||
ASSERT_ALWAYS(*(uint32*)object == 0xdeadbeef);
|
||||
}
|
||||
#endif
|
||||
|
||||
add_alloc_tracing_entry(cache, flags, object);
|
||||
return fill_allocated_block(object, cache->object_size);
|
||||
|
||||
Reference in New Issue
Block a user