diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-12-26 00:52:33 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-26 11:26:39 +0100 |
commit | 7757d874adc269dce5b6ee44792b6c5a3841ff58 (patch) | |
tree | bf490f33306cd8564db568a7d8ca9293ccb57090 /Kernel | |
parent | 1c99f99e995e348ffb5f7726c4f068f66ab08aa4 (diff) | |
download | serenity-7757d874adc269dce5b6ee44792b6c5a3841ff58.zip |
Kernel: Assert that a KmallocSubheap fits inside a page
Since we allocate the subheap in the first page of the given storage
let's assert that the subheap can actually fit in a single page, to
prevent the possible future headache of trying to debug the cause of
random kernel memory corruption :^)
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Heap/kmalloc.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Kernel/Heap/kmalloc.cpp b/Kernel/Heap/kmalloc.cpp index 7eb3bf0ddb..613669d5b4 100644 --- a/Kernel/Heap/kmalloc.cpp +++ b/Kernel/Heap/kmalloc.cpp @@ -58,6 +58,7 @@ struct KmallocGlobalData { void add_subheap(u8* storage, size_t storage_size) { dbgln("Adding kmalloc subheap @ {} with size {}", storage, storage_size); + static_assert(sizeof(KmallocSubheap) <= PAGE_SIZE); auto* subheap = new (storage) KmallocSubheap(storage + PAGE_SIZE, storage_size - PAGE_SIZE); subheaps.append(*subheap); } |