The block size is typically around 4K. Complain if it is much larger,
since this can cause problems with 32-bit arithmetic.

Signed-off-by: Simon Glass <s...@chromium.org>
---

(no changes since v1)

 fs/ext4/ext4_write.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index e77fb383a90..9b1e26e86a7 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -608,6 +608,10 @@ int ext4fs_init(void)
        uint32_t real_free_blocks = 0;
        struct ext_filesystem *fs = get_fs();
 
+       /* check for a reasonable block size, no more than 64K */
+       if (LOG2_BLOCK_SIZE(ext4fs_root) > 16)
+               goto fail;
+
        /* populate fs */
        fs->blksz = EXT2_BLOCK_SIZE(ext4fs_root);
        fs->sect_perblk = fs->blksz >> fs->dev_desc->log2blksz;
-- 
2.43.0

Reply via email to