linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5 v2] vfs: Avoid creation of directory loops for corrupted filesystems
@ 2012-06-20 20:58 Jan Kara
  2012-06-20 20:58 ` [PATCH 2/5] ext2: Handle error from d_splice_alias() Jan Kara
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Jan Kara @ 2012-06-20 20:58 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-fsdevel, Jan Kara, J. Bruce Fields

When a directory hierarchy is corrupted (e. g. due to a bit flip on the media),
it can happen that it contains loops of directories. That creates possibilities
for deadlock when locking directories.

Fix the problem by checking in d_splice_alias() that when we splice a
directory, it does not have any other connected alias.

Reported-by: Sami Liedes <sami.liedes@iki.fi>
CC: "J. Bruce Fields" <bfields@fieldses.org>
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/dcache.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

  Sorry guys, I'm resending this again because I messed up list address
previously.

diff --git a/fs/dcache.c b/fs/dcache.c
index 4046904..afe81fe 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1658,6 +1658,11 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
 			d_move(new, dentry);
 			iput(inode);
 		} else {
+			if (unlikely(!list_empty(&inode->i_dentry))) {
+				spin_unlock(&inode->i_lock);
+				iput(inode);
+				return ERR_PTR(-EIO);
+			}
 			/* already taking inode->i_lock, so d_add() by hand */
 			__d_instantiate(dentry, inode);
 			spin_unlock(&inode->i_lock);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-06-28  8:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-20 20:58 [PATCH 1/5 v2] vfs: Avoid creation of directory loops for corrupted filesystems Jan Kara
2012-06-20 20:58 ` [PATCH 2/5] ext2: Handle error from d_splice_alias() Jan Kara
2012-06-20 20:58 ` [PATCH 3/5] ext3: " Jan Kara
2012-06-20 20:58 ` [PATCH 4/5] ext4: " Jan Kara
2012-06-20 20:58 ` [PATCH 5/5] exofs: " Jan Kara
2012-06-28  8:30 ` [PATCH 1/5 v2] vfs: Avoid creation of directory loops for corrupted filesystems Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).