* [PATCH] udf: Fix deadlock in udf_release_file()
@ 2012-02-20 16:54 Jan Kara
2012-02-20 19:14 ` Namjae Jeon
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2012-02-20 16:54 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Al Viro, Jan Kara
udf_release_file() can be called from munmap() path with mmap_sem held. Thus
we cannot take i_mutex there because that ranks above mmap_sem. Luckily,
i_mutex is not needed in udf_release_file() anymore since protection by
i_data_sem is enough to protect from races with write and truncate.
Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/udf/file.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
If noone objects, I will add this patch to my tree and push it to Linus.
diff --git a/fs/udf/file.c b/fs/udf/file.c
index dca0c38..d567b84 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -201,12 +201,10 @@ out:
static int udf_release_file(struct inode *inode, struct file *filp)
{
if (filp->f_mode & FMODE_WRITE) {
- mutex_lock(&inode->i_mutex);
down_write(&UDF_I(inode)->i_data_sem);
udf_discard_prealloc(inode);
udf_truncate_tail_extent(inode);
up_write(&UDF_I(inode)->i_data_sem);
- mutex_unlock(&inode->i_mutex);
}
return 0;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] udf: Fix deadlock in udf_release_file()
2012-02-20 16:54 [PATCH] udf: Fix deadlock in udf_release_file() Jan Kara
@ 2012-02-20 19:14 ` Namjae Jeon
2012-02-20 22:22 ` Jan Kara
0 siblings, 1 reply; 3+ messages in thread
From: Namjae Jeon @ 2012-02-20 19:14 UTC (permalink / raw)
To: Jan Kara; +Cc: linux-fsdevel, Al Viro, stable
2012/2/21 Jan Kara <jack@suse.cz>:
> udf_release_file() can be called from munmap() path with mmap_sem held. Thus
> we cannot take i_mutex there because that ranks above mmap_sem. Luckily,
> i_mutex is not needed in udf_release_file() anymore since protection by
> i_data_sem is enough to protect from races with write and truncate.
>
> Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
> Signed-off-by: Jan Kara <jack@suse.cz>
HI. Jan.
Looks reasonable to me. And I think that this patch should be added in
stable kernel.
So I add cc: stable@vger.kernel.org.
Reviewed-by: Namjae Jeon <linkinjeon@gmail.com>
> ---
> fs/udf/file.c | 2 --
> 1 files changed, 0 insertions(+), 2 deletions(-)
>
> If noone objects, I will add this patch to my tree and push it to Linus.
>
> diff --git a/fs/udf/file.c b/fs/udf/file.c
> index dca0c38..d567b84 100644
> --- a/fs/udf/file.c
> +++ b/fs/udf/file.c
> @@ -201,12 +201,10 @@ out:
> static int udf_release_file(struct inode *inode, struct file *filp)
> {
> if (filp->f_mode & FMODE_WRITE) {
> - mutex_lock(&inode->i_mutex);
> down_write(&UDF_I(inode)->i_data_sem);
> udf_discard_prealloc(inode);
> udf_truncate_tail_extent(inode);
> up_write(&UDF_I(inode)->i_data_sem);
> - mutex_unlock(&inode->i_mutex);
> }
> return 0;
> }
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] udf: Fix deadlock in udf_release_file()
2012-02-20 19:14 ` Namjae Jeon
@ 2012-02-20 22:22 ` Jan Kara
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kara @ 2012-02-20 22:22 UTC (permalink / raw)
To: Namjae Jeon; +Cc: Jan Kara, linux-fsdevel, Al Viro, stable
On Tue 21-02-12 04:14:50, Namjae Jeon wrote:
> 2012/2/21 Jan Kara <jack@suse.cz>:
> > udf_release_file() can be called from munmap() path with mmap_sem held. Thus
> > we cannot take i_mutex there because that ranks above mmap_sem. Luckily,
> > i_mutex is not needed in udf_release_file() anymore since protection by
> > i_data_sem is enough to protect from races with write and truncate.
> >
> > Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
> > Signed-off-by: Jan Kara <jack@suse.cz>
> HI. Jan.
> Looks reasonable to me. And I think that this patch should be added in
> stable kernel.
> So I add cc: stable@vger.kernel.org.
Good point. Added.
> Reviewed-by: Namjae Jeon <linkinjeon@gmail.com>
Thanks.
Honza
> > ---
> > fs/udf/file.c | 2 --
> > 1 files changed, 0 insertions(+), 2 deletions(-)
> >
> > If noone objects, I will add this patch to my tree and push it to Linus.
> >
> > diff --git a/fs/udf/file.c b/fs/udf/file.c
> > index dca0c38..d567b84 100644
> > --- a/fs/udf/file.c
> > +++ b/fs/udf/file.c
> > @@ -201,12 +201,10 @@ out:
> > static int udf_release_file(struct inode *inode, struct file *filp)
> > {
> > if (filp->f_mode & FMODE_WRITE) {
> > - mutex_lock(&inode->i_mutex);
> > down_write(&UDF_I(inode)->i_data_sem);
> > udf_discard_prealloc(inode);
> > udf_truncate_tail_extent(inode);
> > up_write(&UDF_I(inode)->i_data_sem);
> > - mutex_unlock(&inode->i_mutex);
> > }
> > return 0;
> > }
> > --
> > 1.7.1
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-02-20 22:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-20 16:54 [PATCH] udf: Fix deadlock in udf_release_file() Jan Kara
2012-02-20 19:14 ` Namjae Jeon
2012-02-20 22:22 ` 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).