Skip to contentSkip to conversation

ext4: reject inodes with negative size

PATCH Applied Darrick J. Wong 2 participants 2 messages Dec 6, 2016 – Dec 10, 2016 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: reject inodes with negative size

Don't load an inode with a negative size; this causes integer overflow problems in the VFS.

---
 fs/ext4/inode.c |    4 ++++
 1 file changed, 4 insertions(+)
fs/ext4/inode.c +4 -0
index 9c06472..b1108a9 100644
@@ -4534,6 +4534,10 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
 		ei->i_file_acl |=
 			((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32;
 	inode->i_size = ext4_isize(raw_inode);
+	if (i_size_read(inode) < 0) {
+		ret = -EFSCORRUPTED;
+		goto bad_inode;
+	}
 	ei->i_disksize = inode->i_size;
 #ifdef CONFIG_QUOTA
 	ei->i_reserved_quota = 0;
maintainer Applied
#1 lore raw
Quoted 4 lines · Darrick J. Wong

Don't load an inode with a negative size; this causes integer overflow problems in the VFS.

Thanks, applied. I added a call to EXT4_ERROR_INODE() so the file system would be marked corrupted.

- Ted