diff options
author | Andreas Dilger <adilger@dilger.ca> | 2012-05-28 17:02:25 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2012-05-28 17:02:25 -0400 |
commit | 7e936b737211e6b54e34b71a827e56b872e958d8 (patch) | |
tree | aca4b57eb1982d2cd21bcaa0cbabc45500f97026 /fs/ext4 | |
parent | 967ac8af4475ce45474800709b12137aa7634c77 (diff) | |
download | linux-7e936b737211e6b54e34b71a827e56b872e958d8.tar.gz linux-7e936b737211e6b54e34b71a827e56b872e958d8.tar.bz2 linux-7e936b737211e6b54e34b71a827e56b872e958d8.zip |
ext4: disallow hard-linked directory in ext4_lookup
A hard-linked directory to its parent can cause the VFS to deadlock,
and is a sign of a corrupted file system. So detect this case in
ext4_lookup(), before the rmdir() lockup scenario can take place.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@kernel.org
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/namei.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index a9fd5f48f3bf..daf8260f0b03 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1330,6 +1330,12 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, stru EXT4_ERROR_INODE(dir, "bad inode number: %u", ino); return ERR_PTR(-EIO); } + if (unlikely(ino == dir->i_ino)) { + EXT4_ERROR_INODE(dir, "'%.*s' linked to parent dir", + dentry->d_name.len, + dentry->d_name.name); + return ERR_PTR(-EIO); + } inode = ext4_iget(dir->i_sb, ino); if (inode == ERR_PTR(-ESTALE)) { EXT4_ERROR_INODE(dir, |