From 63e1b904a4839c224a22572c7481293f485f5ae2 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 26 Dec 2021 18:53:04 +0100 Subject: Kernel: Scrub kmalloc slabs when allocated and deallocated This matches the behavior of the generic subheaps (and the old slab allocator implementation.) --- Kernel/Heap/kmalloc.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Kernel/Heap') 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); -- cgit v1.2.3