mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-28 16:56:26 +00:00
exfat: fix file being changed by unaligned direct write
Unaligned direct writes are invalid and should return an error
without making any changes, rather than extending ->valid_size
and then returning an error. Therefore, alignment checking is
required before extending ->valid_size.
Fixes: 11a347fb6c
("exfat: change to get file size from DataLength")
Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Co-developed-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
parent
02dffe9ab0
commit
2e94e5bb94
@ -584,6 +584,16 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)
|
||||
if (ret < 0)
|
||||
goto unlock;
|
||||
|
||||
if (iocb->ki_flags & IOCB_DIRECT) {
|
||||
unsigned long align = pos | iov_iter_alignment(iter);
|
||||
|
||||
if (!IS_ALIGNED(align, i_blocksize(inode)) &&
|
||||
!IS_ALIGNED(align, bdev_logical_block_size(inode->i_sb->s_bdev))) {
|
||||
ret = -EINVAL;
|
||||
goto unlock;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos > valid_size) {
|
||||
ret = exfat_extend_valid_size(file, pos);
|
||||
if (ret < 0 && ret != -ENOSPC) {
|
||||
|
Loading…
Reference in New Issue
Block a user