From: Daniel Munic <[email protected]>
ext4fs_update() iterates over all block groups with a signed 16-bit
loop counter:
short i;
...
for (i = 0; i < fs->no_blkgrp; i++)
fs->no_blkgrp is a uint32_t. On a filesystem with more than 32767
block groups the counter cannot represent every index: incrementing
past SHRT_MAX is signed overflow (undefined behaviour) and the
comparison against the unsigned no_blkgrp never terminates correctly,
so the bitmap/group-descriptor write-back loops misbehave. The mixed
signed/unsigned comparison is also flagged by static analysis.
Use u32 for the loop counter, matching the width of no_blkgrp.
Signed-off-by: Daniel Munic <[email protected]>
Signed-off-by: Sriram Sriram <[email protected]>
---
fs/ext4/ext4_write.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index 1abedcede72..2fba2197c19 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -67,7 +67,7 @@ static inline void ext4fs_bg_free_blocks_inc
static void ext4fs_update(void)
{
- short i;
+ u32 i;
ext4fs_update_journal();
struct ext_filesystem *fs = get_fs();
struct ext2_block_group *bgd = NULL;
--
2.49.0