diff options
author | Theodore Ts'o <tytso@mit.edu> | 2009-06-02 08:09:26 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-06-11 20:01:51 -0700 |
commit | ee098c1e0aafeae998f730a4864e5ef71970d132 (patch) | |
tree | 2a3d24ceaf10529bb9acc894855025d35f38b9ec | |
parent | 5f1839fa7f1f9431fe85dc512ed765caf96bdc1f (diff) | |
download | lwn-ee098c1e0aafeae998f730a4864e5ef71970d132.tar.gz lwn-ee098c1e0aafeae998f730a4864e5ef71970d132.zip |
ext4: Check for an valid i_mode when reading the inode from disk
(cherry picked from commit 563bdd61fe4dbd6b58cf7eb06f8d8f14479ae1dc)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | fs/ext4/inode.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 06fe69415d9c..2bd8005e4758 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4129,7 +4129,8 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) inode->i_op = &ext4_symlink_inode_operations; ext4_set_aops(inode); } - } else { + } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || + S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { inode->i_op = &ext4_special_inode_operations; if (raw_inode->i_block[0]) init_special_inode(inode, inode->i_mode, @@ -4137,6 +4138,13 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) else init_special_inode(inode, inode->i_mode, new_decode_dev(le32_to_cpu(raw_inode->i_block[1]))); + } else { + brelse(bh); + ret = -EIO; + ext4_error(inode->i_sb, __func__, + "bogus i_mode (%o) for inode=%lu", + inode->i_mode, inode->i_ino); + goto bad_inode; } brelse (iloc.bh); ext4_set_inode_flags(inode); |