Skip to content

Commit bb0a12c

Browse files
Kemeng Shitytso
authored andcommitted
ext4: avoid negative min_clusters in find_group_orlov()
min_clusters is signed integer and will be converted to unsigned integer when compared with unsigned number stats.free_clusters. If min_clusters is negative, it will be converted to a huge unsigned value in which case all groups may not meet the actual desired free clusters. Set negative min_clusters to 0 to avoid unexpected behavior. Fixes: ac27a0e ("[PATCH] ext4: initial copy of files from ext3") Signed-off-by: Kemeng Shi <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 227d31b commit bb0a12c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/ext4/ialloc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,8 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
514514
if (min_inodes < 1)
515515
min_inodes = 1;
516516
min_clusters = avefreec - EXT4_CLUSTERS_PER_GROUP(sb)*flex_size / 4;
517+
if (min_clusters < 0)
518+
min_clusters = 0;
517519

518520
/*
519521
* Start looking in the flex group where we last allocated an

0 commit comments

Comments
 (0)