From 2065a737275307fa2322d811c14fb070a54fc7c7 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Tue, 25 Jan 2022 20:24:48 +0200 Subject: [PATCH] Kernel: Use u64 instead of size_t for BlockBasedFileSystem::read_block This ensures offsets will not be truncated on large filesystems on i686 --- Kernel/FileSystem/BlockBasedFileSystem.cpp | 4 ++-- Kernel/FileSystem/BlockBasedFileSystem.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Kernel/FileSystem/BlockBasedFileSystem.cpp b/Kernel/FileSystem/BlockBasedFileSystem.cpp index 6361c90178..8e7bee709a 100644 --- a/Kernel/FileSystem/BlockBasedFileSystem.cpp +++ b/Kernel/FileSystem/BlockBasedFileSystem.cpp @@ -212,7 +212,7 @@ ErrorOr BlockBasedFileSystem::write_blocks(BlockIndex index, unsigned coun return {}; } -ErrorOr BlockBasedFileSystem::read_block(BlockIndex index, UserOrKernelBuffer* buffer, size_t count, size_t offset, bool allow_cache) const +ErrorOr BlockBasedFileSystem::read_block(BlockIndex index, UserOrKernelBuffer* buffer, size_t count, u64 offset, bool allow_cache) const { VERIFY(m_logical_block_size); VERIFY(offset + count <= block_size()); @@ -221,7 +221,7 @@ ErrorOr BlockBasedFileSystem::read_block(BlockIndex index, UserOrKernelBuf return m_cache.with_exclusive([&](auto& cache) -> ErrorOr { if (!allow_cache) { const_cast(this)->flush_specific_block_if_needed(index); - auto base_offset = index.value() * block_size() + offset; + u64 base_offset = index.value() * block_size() + offset; auto nread = TRY(file_description().read(*buffer, base_offset, count)); VERIFY(nread == count); return {}; diff --git a/Kernel/FileSystem/BlockBasedFileSystem.h b/Kernel/FileSystem/BlockBasedFileSystem.h index 2355aba79b..235ab2935c 100644 --- a/Kernel/FileSystem/BlockBasedFileSystem.h +++ b/Kernel/FileSystem/BlockBasedFileSystem.h @@ -26,7 +26,7 @@ public: protected: explicit BlockBasedFileSystem(OpenFileDescription&); - ErrorOr read_block(BlockIndex, UserOrKernelBuffer*, size_t count, size_t offset = 0, bool allow_cache = true) const; + ErrorOr read_block(BlockIndex, UserOrKernelBuffer*, size_t count, u64 offset = 0, bool allow_cache = true) const; ErrorOr read_blocks(BlockIndex, unsigned count, UserOrKernelBuffer&, bool allow_cache = true) const; ErrorOr raw_read(BlockIndex, UserOrKernelBuffer&);