diff options
author | Andreas Kling <kling@serenityos.org> | 2021-03-10 16:24:01 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-10 16:33:47 +0100 |
commit | e58a600d52be5544cab0e770b372488e35a38811 (patch) | |
tree | 9d51e0ccc79450b223f4d631b3b2225576b83c13 /Kernel/FileSystem/Ext2FileSystem.cpp | |
parent | 3dbb9c8448a23ad1405d415922b3b6e4e9bfe78b (diff) | |
download | serenity-e58a600d52be5544cab0e770b372488e35a38811.zip |
Kernel: Remove VLA usage in Ext2FS block traversal code
This was using up to 12KB of kernel stack in the triply indirect case
and looks generally spooky. Let's just allocate a ByteBuffer for now
and take the performance hit (of heap allocation). Longer term we can
reorganize the code to reduce the majority of the heap churn.
Diffstat (limited to 'Kernel/FileSystem/Ext2FileSystem.cpp')
-rw-r--r-- | Kernel/FileSystem/Ext2FileSystem.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index d5f751f72b..4fadf8f70f 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -506,9 +506,11 @@ Vector<Ext2FS::BlockIndex> Ext2FSInode::compute_block_list_impl_internal(const e auto count = min(blocks_remaining, entries_per_block); if (!count) return; - u32 array[count]; + size_t read_size = count * sizeof(u32); + auto array_storage = ByteBuffer::create_uninitialized(read_size); + auto* array = (u32*)array_storage.data(); auto buffer = UserOrKernelBuffer::for_kernel_buffer((u8*)array); - auto result = fs().read_block(array_block_index, &buffer, sizeof(array), 0); + auto result = fs().read_block(array_block_index, &buffer, read_size, 0); if (result.is_error()) { // FIXME: Stop here and propagate this error. dbgln("Ext2FS: compute_block_list_impl_internal had error: {}", result.error()); |