diff options
author | Andreas Kling <kling@serenityos.org> | 2020-02-26 13:21:31 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-26 15:25:53 +0100 |
commit | 987dbedf4ad41d6ace7b9549a3953a9e7a62515a (patch) | |
tree | b184abcab26d083929ebe302e5f01e5213169814 /Kernel | |
parent | a57f074187e0f40781a4a4f71ba08c283586b800 (diff) | |
download | serenity-987dbedf4ad41d6ace7b9549a3953a9e7a62515a.zip |
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().
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Heap/SlabAllocator.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Kernel/Heap/SlabAllocator.cpp b/Kernel/Heap/SlabAllocator.cpp index 0aed1747a9..b2a4416faa 100644 --- a/Kernel/Heap/SlabAllocator.cpp +++ b/Kernel/Heap/SlabAllocator.cpp @@ -29,6 +29,8 @@ #include <Kernel/Heap/kmalloc.h> #include <Kernel/VM/Region.h> +#define SANITIZE_SLABS + namespace Kernel { template<size_t templated_slab_size> @@ -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 |