Skip to content

Commit 4b36399

Browse files
zhangyi089gregkh
authored andcommitted
ext4: ensure i_size is smaller than maxbytes
commit 1a77a02 upstream. The inode i_size cannot be larger than maxbytes, check it while loading inode from the disk. Signed-off-by: Zhang Yi <yi.zhang@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Baokun Li <libaokun1@huawei.com> Link: https://patch.msgid.link/20250506012009.3896990-4-yi.zhang@huaweicloud.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b841ca8 commit 4b36399

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/ext4/inode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4928,7 +4928,8 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
49284928
ei->i_file_acl |=
49294929
((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32;
49304930
inode->i_size = ext4_isize(sb, raw_inode);
4931-
if ((size = i_size_read(inode)) < 0) {
4931+
size = i_size_read(inode);
4932+
if (size < 0 || size > ext4_get_maxbytes(inode)) {
49324933
ext4_error_inode(inode, function, line, 0,
49334934
"iget: bad i_size value: %lld", size);
49344935
ret = -EFSCORRUPTED;

0 commit comments

Comments
 (0)