diff options
author | Andreas Kling <kling@serenityos.org> | 2021-12-26 18:53:04 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-26 21:22:59 +0100 |
commit | 63e1b904a4839c224a22572c7481293f485f5ae2 (patch) | |
tree | 68ae772acfda02c39b69338d24caaeb73109b962 /Kernel/Heap | |
parent | 3399b6c57f024665c041e756484f0af23fa53368 (diff) | |
download | serenity-63e1b904a4839c224a22572c7481293f485f5ae2.zip |
Kernel: Scrub kmalloc slabs when allocated and deallocated
This matches the behavior of the generic subheaps (and the old slab
allocator implementation.)
Diffstat (limited to 'Kernel/Heap')
-rw-r--r-- | Kernel/Heap/kmalloc.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Kernel/Heap/kmalloc.cpp b/Kernel/Heap/kmalloc.cpp index f19c4354c9..147f502716 100644 --- a/Kernel/Heap/kmalloc.cpp +++ b/Kernel/Heap/kmalloc.cpp @@ -119,11 +119,15 @@ public: auto* ptr = block->allocate(); if (block->is_full()) m_full_blocks.append(*block); + + memset(ptr, KMALLOC_SCRUB_BYTE, m_slab_size); return ptr; } void deallocate(void* ptr) { + memset(ptr, KFREE_SCRUB_BYTE, m_slab_size); + auto* block = (KmallocSlabBlock*)((FlatPtr)ptr & KmallocSlabBlock::block_mask); bool block_was_full = block->is_full(); block->deallocate(ptr); |