diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2016-12-10 09:55:01 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-01-06 04:40:14 -0500 |
commit | 3e4f8da9d177b447fdd5e82c94f66bac38aa3045 (patch) | |
tree | 240f5dbed3aad832e2352e449b7c4f3d64fcf346 /fs | |
parent | 8084f57bc46894dbe08dac2a09d66553d7513a34 (diff) |
ext4: reject inodes with negative size
commit 7e6e1ef48fc02f3ac5d0edecbb0c6087cd758d58 upstream.
Don't load an inode with a negative size; this causes integer overflow
problems in the VFS.
[ Added EXT4_ERROR_INODE() to mark file system as corrupted. -TYT]
Fixes: a48380f769df (ext4: rename i_dir_acl to i_size_high)
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/inode.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 9c064727ed62..33a509c876ee 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -4434,6 +4434,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) | |||
4434 | struct inode *inode; | 4434 | struct inode *inode; |
4435 | journal_t *journal = EXT4_SB(sb)->s_journal; | 4435 | journal_t *journal = EXT4_SB(sb)->s_journal; |
4436 | long ret; | 4436 | long ret; |
4437 | loff_t size; | ||
4437 | int block; | 4438 | int block; |
4438 | uid_t i_uid; | 4439 | uid_t i_uid; |
4439 | gid_t i_gid; | 4440 | gid_t i_gid; |
@@ -4534,6 +4535,11 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) | |||
4534 | ei->i_file_acl |= | 4535 | ei->i_file_acl |= |
4535 | ((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32; | 4536 | ((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32; |
4536 | inode->i_size = ext4_isize(raw_inode); | 4537 | inode->i_size = ext4_isize(raw_inode); |
4538 | if ((size = i_size_read(inode)) < 0) { | ||
4539 | EXT4_ERROR_INODE(inode, "bad i_size value: %lld", size); | ||
4540 | ret = -EFSCORRUPTED; | ||
4541 | goto bad_inode; | ||
4542 | } | ||
4537 | ei->i_disksize = inode->i_size; | 4543 | ei->i_disksize = inode->i_size; |
4538 | #ifdef CONFIG_QUOTA | 4544 | #ifdef CONFIG_QUOTA |
4539 | ei->i_reserved_quota = 0; | 4545 | ei->i_reserved_quota = 0; |