diff options
author | Jan Kara <jack@suse.cz> | 2009-08-07 00:27:27 +0200 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2009-09-14 19:13:01 +0200 |
commit | cbc8cc33529b0e0e55ae0ff077b8cb0b71d54c7a (patch) | |
tree | 5edace261ca6d707456d1bde03c0bf719ac8a365 /fs/udf/file.c | |
parent | udf: Perform preallocation only for regular files (diff) | |
download | linux-cbc8cc33529b0e0e55ae0ff077b8cb0b71d54c7a.tar.xz linux-cbc8cc33529b0e0e55ae0ff077b8cb0b71d54c7a.zip |
udf: Fix possible corruption when close races with write
When we close a file, we remove preallocated blocks from it. But this
truncation was not protected by i_mutex and thus it could have raced with a
write through a different fd and cause crashes or even filesystem corruption.
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to '')
-rw-r--r-- | fs/udf/file.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/udf/file.c b/fs/udf/file.c index 7464305382b5..b80cbd78833c 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -193,9 +193,11 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, static int udf_release_file(struct inode *inode, struct file *filp) { if (filp->f_mode & FMODE_WRITE) { + mutex_lock(&inode->i_mutex); lock_kernel(); udf_discard_prealloc(inode); unlock_kernel(); + mutex_unlock(&inode->i_mutex); } return 0; } |