diff options
author | Andreas Dilger <adilger@dilger.ca> | 2012-05-28 17:02:25 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-06-10 00:36:16 +0900 |
commit | c40a4bd1e80db2b3af7b064b6eece0e689be60a9 (patch) | |
tree | 4dfa6bac93d96e90a109736d1d0425ed3d86c72c /fs/ext4 | |
parent | a9ea4481033197d29c606a935b24336a96cb3082 (diff) | |
download | lwn-c40a4bd1e80db2b3af7b064b6eece0e689be60a9.tar.gz lwn-c40a4bd1e80db2b3af7b064b6eece0e689be60a9.zip |
ext4: disallow hard-linked directory in ext4_lookup
commit 7e936b737211e6b54e34b71a827e56b872e958d8 upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.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 349d7b3671c8..0a94cbbe8828 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1037,6 +1037,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, |