* [PATCH] ext2: reject inodes with negative size
@ 2016-12-06 23:59 Darrick J. Wong
2016-12-07 12:05 ` Jan Kara
0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2016-12-06 23:59 UTC (permalink / raw)
To: Theodore Ts'o, Jan Kara; +Cc: linux-ext4
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>
---
fs/ext2/inode.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 41b8b44..01f6d4b 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;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ext2: reject inodes with negative size
2016-12-06 23:59 [PATCH] ext2: reject inodes with negative size Darrick J. Wong
@ 2016-12-07 12:05 ` Jan Kara
0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2016-12-07 12:05 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Theodore Ts'o, Jan Kara, linux-ext4
On Tue 06-12-16 15:59:01, Darrick J. Wong wrote:
> 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>
Thanks, I've added the patch to my tree.
Honza
> ---
> fs/ext2/inode.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
> index 41b8b44..01f6d4b 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;
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-07 12:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-06 23:59 [PATCH] ext2: reject inodes with negative size Darrick J. Wong
2016-12-07 12:05 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).