Message ID | 20230518010221.163474-1-cengiz.can@canonical.com |
---|---|
State | New |
Headers | show |
Series | [SRU,Focal,1/2] ext4: check if directory block is within i_size | expand |
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 4e94b6bd99bc..db008809fa40 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -125,6 +125,13 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode, struct ext4_dir_entry *dirent; int is_dx_block = 0; + if (block >= inode->i_size) { + ext4_error_inode(inode, func, line, block, + "Attempting to read directory block (%u) that is past i_size (%llu)", + block, inode->i_size); + return ERR_PTR(-EFSCORRUPTED); + } + if (ext4_simulate_fail(inode->i_sb, EXT4_SIM_DIRBLOCK_EIO)) bh = ERR_PTR(-EIO); else