aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2014-10-05 22:56:00 -0400
committerTheodore Ts'o <tytso@mit.edu>2014-10-05 22:56:00 -0400
commitf4bb2981024fc91b23b4d09a8817c415396dbabb (patch)
tree7645d062e8808ab71b81b542c388e47d8b78b35f /fs
parente2bfb088fac03c0f621886a04cffc7faa2b49b1d (diff)
ext4: add ext4_iget_normal() which is to be used for dir tree lookups
If there is a corrupted file system which has directory entries that point at reserved, metadata inodes, prohibit them from being used by treating them the same way we treat Boot Loader inodes --- that is, mark them to be bad inodes. This prohibits them from being opened, deleted, or modified via chmod, chown, utimes, etc. In particular, this prevents a corrupted file system which has a directory entry which points at the journal inode from being deleted and its blocks released, after which point Much Hilarity Ensues. Reported-by: Sami Liedes <sami.liedes@iki.fi> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@vger.kernel.org
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/ext4.h1
-rw-r--r--fs/ext4/inode.c7
-rw-r--r--fs/ext4/namei.c4
-rw-r--r--fs/ext4/super.c2
4 files changed, 11 insertions, 3 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 1eb5b7b912a8..012e89bd9644 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2109,6 +2109,7 @@ int do_journal_get_write_access(handle_t *handle,
2109#define CONVERT_INLINE_DATA 2 2109#define CONVERT_INLINE_DATA 2
2110 2110
2111extern struct inode *ext4_iget(struct super_block *, unsigned long); 2111extern struct inode *ext4_iget(struct super_block *, unsigned long);
2112extern struct inode *ext4_iget_normal(struct super_block *, unsigned long);
2112extern int ext4_write_inode(struct inode *, struct writeback_control *); 2113extern int ext4_write_inode(struct inode *, struct writeback_control *);
2113extern int ext4_setattr(struct dentry *, struct iattr *); 2114extern int ext4_setattr(struct dentry *, struct iattr *);
2114extern int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry, 2115extern int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry,
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 59983b28a93c..e204d8aabe7d 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4104,6 +4104,13 @@ bad_inode:
4104 return ERR_PTR(ret); 4104 return ERR_PTR(ret);
4105} 4105}
4106 4106
4107struct inode *ext4_iget_normal(struct super_block *sb, unsigned long ino)
4108{
4109 if (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO)
4110 return ERR_PTR(-EIO);
4111 return ext4_iget(sb, ino);
4112}
4113
4107static int ext4_inode_blocks_set(handle_t *handle, 4114static int ext4_inode_blocks_set(handle_t *handle,
4108 struct ext4_inode *raw_inode, 4115 struct ext4_inode *raw_inode,
4109 struct ext4_inode_info *ei) 4116 struct ext4_inode_info *ei)
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index a2a9d40522d2..7037ecf0fc23 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1417,7 +1417,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
1417 dentry); 1417 dentry);
1418 return ERR_PTR(-EIO); 1418 return ERR_PTR(-EIO);
1419 } 1419 }
1420 inode = ext4_iget(dir->i_sb, ino); 1420 inode = ext4_iget_normal(dir->i_sb, ino);
1421 if (inode == ERR_PTR(-ESTALE)) { 1421 if (inode == ERR_PTR(-ESTALE)) {
1422 EXT4_ERROR_INODE(dir, 1422 EXT4_ERROR_INODE(dir,
1423 "deleted inode referenced: %u", 1423 "deleted inode referenced: %u",
@@ -1450,7 +1450,7 @@ struct dentry *ext4_get_parent(struct dentry *child)
1450 return ERR_PTR(-EIO); 1450 return ERR_PTR(-EIO);
1451 } 1451 }
1452 1452
1453 return d_obtain_alias(ext4_iget(child->d_inode->i_sb, ino)); 1453 return d_obtain_alias(ext4_iget_normal(child->d_inode->i_sb, ino));
1454} 1454}
1455 1455
1456/* 1456/*
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 1070d6e521c6..a0811cc00c91 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1001,7 +1001,7 @@ static struct inode *ext4_nfs_get_inode(struct super_block *sb,
1001 * Currently we don't know the generation for parent directory, so 1001 * Currently we don't know the generation for parent directory, so
1002 * a generation of 0 means "accept any" 1002 * a generation of 0 means "accept any"
1003 */ 1003 */
1004 inode = ext4_iget(sb, ino); 1004 inode = ext4_iget_normal(sb, ino);
1005 if (IS_ERR(inode)) 1005 if (IS_ERR(inode))
1006 return ERR_CAST(inode); 1006 return ERR_CAST(inode);
1007 if (generation && inode->i_generation != generation) { 1007 if (generation && inode->i_generation != generation) {