[PATCH v3 08/10] ext4: Set a max limit on block-size in ext4fs_init()
Simon Glass
sjg at chromium.org
Sat May 10 15:06:14 CEST 2025
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 <sjg at 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
More information about the U-Boot
mailing list