Skip to content

Commit

Permalink
ext2: reject inodes with negative size
Browse files Browse the repository at this point in the history
Don't load an inode with a negative size; this causes integer overflow
problems in the VFS.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Jan Kara <jack@suse.cz>
  • Loading branch information
Darrick J. Wong authored and Jan Kara committed Dec 7, 2016
1 parent c3b0044 commit b46dc03
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/ext2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,10 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
inode->i_size |= ((__u64)le32_to_cpu(raw_inode->i_size_high)) << 32;
else
ei->i_dir_acl = le32_to_cpu(raw_inode->i_dir_acl);
if (i_size_read(inode) < 0) {
ret = -EFSCORRUPTED;
goto bad_inode;
}
ei->i_dtime = 0;
inode->i_generation = le32_to_cpu(raw_inode->i_generation);
ei->i_state = 0;
Expand Down

0 comments on commit b46dc03

Please sign in to comment.