mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-24 23:23:58 +00:00
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().
This commit is contained in:
parent
a57f074187
commit
987dbedf4a
Notes:
sideshowbarker
2024-07-19 09:03:11 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/987dbedf4ad
1 changed files with 4 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue