Patch "exfat: fix file being changed by unaligned direct write" has been added to the 6.12-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    exfat: fix file being changed by unaligned direct write

to the 6.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     exfat-fix-file-being-changed-by-unaligned-direct-wri.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 303c7efb957cdb937fb2ea34fa6351231bdc1cb6
Author: Yuezhang Mo <Yuezhang.Mo@xxxxxxxx>
Date:   Thu Oct 17 09:25:06 2024 +0800

    exfat: fix file being changed by unaligned direct write
    
    [ Upstream commit 2e94e5bb94a3e641a25716a560bf474225fda83c ]
    
    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: 11a347fb6cef ("exfat: change to get file size from DataLength")
    Signed-off-by: Yuezhang Mo <Yuezhang.Mo@xxxxxxxx>
    Co-developed-by: Namjae Jeon <linkinjeon@xxxxxxxxxx>
    Signed-off-by: Namjae Jeon <linkinjeon@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index a25d7eb789f4c..fb38769c3e39d 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -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) {




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux