1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:37:35 +00:00

Kernel: Add memory scrubbing in slab_alloc() and slab_dealloc()

These now scrub allocated and freed memory like kmalloc()/kfree() was
already doing.
This commit is contained in:
Andreas Kling 2020-02-01 10:36:25 +01:00
parent 934b1d8a9b
commit 37d336d741
3 changed files with 16 additions and 0 deletions

View file

@ -61,6 +61,9 @@ public:
m_freelist = m_freelist->next;
++m_num_allocated;
--m_num_free;
#ifdef SANITIZE_KMALLOC
memset(ptr, SLAB_ALLOC_SCRUB_BYTE, slab_size());
#endif
return ptr;
}
@ -73,6 +76,10 @@ public:
return;
}
((FreeSlab*)ptr)->next = m_freelist;
#ifdef SANITIZE_KMALLOC
if (slab_size() > sizeof(FreeSlab*))
memset(((FreeSlab*)ptr)->padding, SLAB_DEALLOC_SCRUB_BYTE, sizeof(FreeSlab::padding));
#endif
m_freelist = (FreeSlab*)ptr;
++m_num_allocated;
--m_num_free;