summaryrefslogtreecommitdiffstats
path: root/fs/udf/file.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2023-01-19 12:46:09 +0100
committerJan Kara <jack@suse.cz>2023-01-26 16:46:35 +0100
commitb9a861fd527ab123e76effb492b4eb7e8115d4ca (patch)
treef51dab17dc5495d57f675b37a7dbd6a131d2daf4 /fs/udf/file.c
parent96eeaaaea592079fcbf0b18a2b6f99165b32c942 (diff)
downloadlinux-stable-b9a861fd527ab123e76effb492b4eb7e8115d4ca.tar.gz
linux-stable-b9a861fd527ab123e76effb492b4eb7e8115d4ca.tar.bz2
linux-stable-b9a861fd527ab123e76effb492b4eb7e8115d4ca.zip
udf: Protect truncate and file type conversion with invalidate_lock
Protect truncate and file type conversion in udf_file_write_iter() with invalidate lock. That will allow us to serialize these paths with page faults so that the page fault can determine the file type in a racefree way. Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf/file.c')
-rw-r--r--fs/udf/file.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 596d703fb6c8..cf050bdffd9e 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -150,7 +150,9 @@ static ssize_t udf_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB &&
inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) +
iocb->ki_pos + iov_iter_count(from))) {
+ filemap_invalidate_lock(inode->i_mapping);
retval = udf_expand_file_adinicb(inode);
+ filemap_invalidate_unlock(inode->i_mapping);
if (retval)
goto out;
}