Skip to content

Commit 47e3536

Browse files
YuezhangMonamjaejeon
authored andcommitted
exfat: fix missing shutdown check
xfstests generic/730 test failed because after deleting the device that still had dirty data, the file could still be read without returning an error. The reason is the missing shutdown check in ->read_iter. I also noticed that shutdown checks were missing from ->write_iter, ->splice_read, and ->mmap. This commit adds shutdown checks to all of them. Fixes: f761fcd ("exfat: Implement sops->shutdown and ioctl") Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 parent b052230 commit 47e3536

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

fs/exfat/file.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,9 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)
582582
loff_t pos = iocb->ki_pos;
583583
loff_t valid_size;
584584

585+
if (unlikely(exfat_forced_shutdown(inode->i_sb)))
586+
return -EIO;
587+
585588
inode_lock(inode);
586589

587590
valid_size = ei->valid_size;
@@ -635,6 +638,16 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)
635638
return ret;
636639
}
637640

641+
static ssize_t exfat_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
642+
{
643+
struct inode *inode = file_inode(iocb->ki_filp);
644+
645+
if (unlikely(exfat_forced_shutdown(inode->i_sb)))
646+
return -EIO;
647+
648+
return generic_file_read_iter(iocb, iter);
649+
}
650+
638651
static vm_fault_t exfat_page_mkwrite(struct vm_fault *vmf)
639652
{
640653
int err;
@@ -672,22 +685,34 @@ static const struct vm_operations_struct exfat_file_vm_ops = {
672685

673686
static int exfat_file_mmap(struct file *file, struct vm_area_struct *vma)
674687
{
688+
if (unlikely(exfat_forced_shutdown(file_inode(file)->i_sb)))
689+
return -EIO;
690+
675691
file_accessed(file);
676692
vma->vm_ops = &exfat_file_vm_ops;
677693
return 0;
678694
}
679695

696+
static ssize_t exfat_splice_read(struct file *in, loff_t *ppos,
697+
struct pipe_inode_info *pipe, size_t len, unsigned int flags)
698+
{
699+
if (unlikely(exfat_forced_shutdown(file_inode(in)->i_sb)))
700+
return -EIO;
701+
702+
return filemap_splice_read(in, ppos, pipe, len, flags);
703+
}
704+
680705
const struct file_operations exfat_file_operations = {
681706
.llseek = generic_file_llseek,
682-
.read_iter = generic_file_read_iter,
707+
.read_iter = exfat_file_read_iter,
683708
.write_iter = exfat_file_write_iter,
684709
.unlocked_ioctl = exfat_ioctl,
685710
#ifdef CONFIG_COMPAT
686711
.compat_ioctl = exfat_compat_ioctl,
687712
#endif
688713
.mmap = exfat_file_mmap,
689714
.fsync = exfat_file_fsync,
690-
.splice_read = filemap_splice_read,
715+
.splice_read = exfat_splice_read,
691716
.splice_write = iter_file_splice_write,
692717
};
693718

0 commit comments

Comments
 (0)