ext2: reject inodes with negative size
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 6 Dec 2016 23:59:01 +0000 (15:59 -0800)
committerJan Kara <jack@suse.cz>
Wed, 7 Dec 2016 12:03:31 +0000 (13:03 +0100)
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>
fs/ext2/inode.c

index 41b8b44a391cb5dc8ed833cb95b632424372e038..01f6d4be7f9aae0bb0a39899e2ab003da6045974 100644 (file)
@@ -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;