]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ext4: Check for an valid i_mode when reading the inode from disk
authorTheodore Ts'o <tytso@mit.edu>
Thu, 26 Mar 2009 04:06:19 +0000 (00:06 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 26 Mar 2009 04:06:19 +0000 (00:06 -0400)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/ext4/inode.c

index bed4a0abd0d13fcb42a2d058c860d1fc3a6d896a..c7d9250fbc3f254c606861e7d89dce723adccacc 100644 (file)
@@ -4394,7 +4394,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,
@@ -4402,6 +4403,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);