From: Darrick J. Wong Date: Tue, 6 Dec 2016 23:59:01 +0000 (-0800) Subject: ext2: reject inodes with negative size X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b46dc033818d3293ecc49dc258e2efb603c80bd7;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git ext2: reject inodes with negative size Don't load an inode with a negative size; this causes integer overflow problems in the VFS. Signed-off-by: Darrick J. Wong Signed-off-by: Jan Kara --- diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 41b8b44a391c..01f6d4be7f9a 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -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;