From 987dbedf4ad41d6ace7b9549a3953a9e7a62515a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 26 Feb 2020 13:21:31 +0100 Subject: [PATCH] Kernel: Sanitize memory coming in/out of the slab allocator We were using SANITIZE_KMALLOC which was never defined in this .cpp file, oops. Now we actually scrub on slab_alloc() and slab_dealloc(). --- Kernel/Heap/SlabAllocator.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Kernel/Heap/SlabAllocator.cpp b/Kernel/Heap/SlabAllocator.cpp index 0aed1747a90..b2a4416faa1 100644 --- a/Kernel/Heap/SlabAllocator.cpp +++ b/Kernel/Heap/SlabAllocator.cpp @@ -29,6 +29,8 @@ #include #include +#define SANITIZE_SLABS + namespace Kernel { template @@ -63,7 +65,7 @@ public: m_freelist = m_freelist->next; ++m_num_allocated; --m_num_free; -#ifdef SANITIZE_KMALLOC +#ifdef SANITIZE_SLABS memset(ptr, SLAB_ALLOC_SCRUB_BYTE, slab_size()); #endif return ptr; @@ -78,7 +80,7 @@ public: return; } ((FreeSlab*)ptr)->next = m_freelist; -#ifdef SANITIZE_KMALLOC +#ifdef SANITIZE_SLABS if (slab_size() > sizeof(FreeSlab*)) memset(((FreeSlab*)ptr)->padding, SLAB_DEALLOC_SCRUB_BYTE, sizeof(FreeSlab::padding)); #endif