inode->i_rwsem should be locked when writing file. But the lock is missing when writing zeros to the file in exfat_file_mmap(). Fixes: 11a347fb6cef ("exfat: change to get file size from DataLength") Signed-off-by: Yuezhang Mo <Yuezhang.Mo@xxxxxxxx> --- fs/exfat/file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/exfat/file.c b/fs/exfat/file.c index d25a96a148af..473c1641d50d 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -613,7 +613,11 @@ static int exfat_file_mmap(struct file *file, struct vm_area_struct *vma) start + vma->vm_end - vma->vm_start); if ((vma->vm_flags & VM_WRITE) && ei->valid_size < end) { + if (!inode_trylock(inode)) + return -EAGAIN; + ret = exfat_file_zeroed_range(file, ei->valid_size, end); + inode_unlock(inode); if (ret < 0) { exfat_err(inode->i_sb, "mmap: fail to zero from %llu to %llu(%d)", -- 2.34.1
Attachment:
0001-exfat-fix-file-not-locking-when-writing-zeros-in-exf.patch
Description: 0001-exfat-fix-file-not-locking-when-writing-zeros-in-exf.patch