From: Jan Kara <jack@suse.cz>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, Jan Kara <jack@suse.cz>,
"J. Bruce Fields" <bfields@fieldses.org>
Subject: [PATCH 1/5 v2] vfs: Avoid creation of directory loops for corrupted filesystems
Date: Wed, 20 Jun 2012 22:58:36 +0200 [thread overview]
Message-ID: <1340225920-29379-1-git-send-email-jack@suse.cz> (raw)
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
next reply other threads:[~2012-06-20 20:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-20 20:58 Jan Kara [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1340225920-29379-1-git-send-email-jack@suse.cz \
--to=jack@suse.cz \
--cc=bfields@fieldses.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).