* [PATCH 2/5] ext2: Handle error from d_splice_alias()
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 ` Jan Kara
2012-06-20 20:58 ` [PATCH 3/5] ext3: " Jan Kara
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jan Kara @ 2012-06-20 20:58 UTC (permalink / raw)
To: Al Viro; +Cc: linux-fsdevel, Jan Kara
When directory hiearchy is corrupted and contains cycles, d_splice_alias() can
fail. Warn user and mark filesystem as with errors when that happens.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext2/namei.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index f663a67..b3f074b 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -59,6 +59,7 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str
{
struct inode * inode;
ino_t ino;
+ struct dentry *ret;
if (dentry->d_name.len > EXT2_NAME_LEN)
return ERR_PTR(-ENAMETOOLONG);
@@ -74,7 +75,12 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str
return ERR_PTR(-EIO);
}
}
- return d_splice_alias(inode, dentry);
+ ret = d_splice_alias(inode, dentry);
+ if (IS_ERR(ret)) {
+ ext2_error(dir->i_sb, __func__, "directory #%lu corrupted",
+ dir->i_ino);
+ }
+ return ret;
}
struct dentry *ext2_get_parent(struct dentry *child)
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/5] ext3: Handle error from d_splice_alias()
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 ` Jan Kara
2012-06-20 20:58 ` [PATCH 4/5] ext4: " Jan Kara
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jan Kara @ 2012-06-20 20:58 UTC (permalink / raw)
To: Al Viro; +Cc: linux-fsdevel, Jan Kara
When directory hiearchy is corrupted and contains cycles, d_splice_alias() can
fail. Warn user and mark filesystem as with errors when that happens.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext3/namei.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index eeb63df..febb9f1 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -1016,6 +1016,7 @@ static struct dentry *ext3_lookup(struct inode * dir, struct dentry *dentry, str
struct inode * inode;
struct ext3_dir_entry_2 * de;
struct buffer_head * bh;
+ struct dentry *ret;
if (dentry->d_name.len > EXT3_NAME_LEN)
return ERR_PTR(-ENAMETOOLONG);
@@ -1038,7 +1039,12 @@ static struct dentry *ext3_lookup(struct inode * dir, struct dentry *dentry, str
return ERR_PTR(-EIO);
}
}
- return d_splice_alias(inode, dentry);
+ ret = d_splice_alias(inode, dentry);
+ if (IS_ERR(ret)) {
+ ext3_error(dir->i_sb, __func__, "directory #%lu corrupted",
+ dir->i_ino);
+ }
+ return ret;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/5] ext4: Handle error from d_splice_alias()
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 ` 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
4 siblings, 0 replies; 6+ messages in thread
From: Jan Kara @ 2012-06-20 20:58 UTC (permalink / raw)
To: Al Viro; +Cc: linux-fsdevel, Jan Kara
When directory hiearchy is corrupted and contains cycles, d_splice_alias() can
fail. Warn user and mark filesystem as with errors when that happens.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext4/namei.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 5845cd9..0cb1a94 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1317,6 +1317,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, stru
struct inode *inode;
struct ext4_dir_entry_2 *de;
struct buffer_head *bh;
+ struct dentry *ret;
if (dentry->d_name.len > EXT4_NAME_LEN)
return ERR_PTR(-ENAMETOOLONG);
@@ -1344,7 +1345,10 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, stru
return ERR_PTR(-EIO);
}
}
- return d_splice_alias(inode, dentry);
+ ret = d_splice_alias(inode, dentry);
+ if (IS_ERR(ret))
+ EXT4_ERROR_INODE(dir, "directory corrupted");
+ return ret;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 5/5] exofs: Handle error from d_splice_alias()
2012-06-20 20:58 [PATCH 1/5 v2] vfs: Avoid creation of directory loops for corrupted filesystems Jan Kara
` (2 preceding siblings ...)
2012-06-20 20:58 ` [PATCH 4/5] ext4: " Jan Kara
@ 2012-06-20 20:58 ` Jan Kara
2012-06-28 8:30 ` [PATCH 1/5 v2] vfs: Avoid creation of directory loops for corrupted filesystems Jan Kara
4 siblings, 0 replies; 6+ messages in thread
From: Jan Kara @ 2012-06-20 20:58 UTC (permalink / raw)
To: Al Viro; +Cc: linux-fsdevel, Boaz Harrosh, Jan Kara
From: Boaz Harrosh <bharrosh@panasas.com>
When directory hierarchy is corrupted and contains cycles, d_splice_alias() can
fail. Warn user if that happens.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/exofs/namei.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c
index fc7161d..6f44d3c 100644
--- a/fs/exofs/namei.c
+++ b/fs/exofs/namei.c
@@ -50,13 +50,17 @@ static struct dentry *exofs_lookup(struct inode *dir, struct dentry *dentry,
{
struct inode *inode;
ino_t ino;
+ struct dentry *ret;
if (dentry->d_name.len > EXOFS_NAME_LEN)
return ERR_PTR(-ENAMETOOLONG);
ino = exofs_inode_by_name(dir, dentry);
inode = ino ? exofs_iget(dir->i_sb, ino) : NULL;
- return d_splice_alias(inode, dentry);
+ ret = d_splice_alias(inode, dentry);
+ if (IS_ERR(ret))
+ EXOFS_ERR("directory #%lu corrupted", dir->i_ino);
+ return ret;
}
static int exofs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/5 v2] vfs: Avoid creation of directory loops for corrupted filesystems
2012-06-20 20:58 [PATCH 1/5 v2] vfs: Avoid creation of directory loops for corrupted filesystems Jan Kara
` (3 preceding siblings ...)
2012-06-20 20:58 ` [PATCH 5/5] exofs: " Jan Kara
@ 2012-06-28 8:30 ` Jan Kara
4 siblings, 0 replies; 6+ messages in thread
From: Jan Kara @ 2012-06-28 8:30 UTC (permalink / raw)
To: Al Viro; +Cc: linux-fsdevel, Jan Kara, J. Bruce Fields
On Wed 20-06-12 22:58:36, Jan Kara wrote:
> 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.
Al, any opinion on this patch series?
Honza
> 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
>
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 6+ messages in thread