Skip to content

Commit

Permalink
exfat: fix missing shutdown check
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Yuezhang Mo authored and Namjae Jeon committed Mar 27, 2025
1 parent b052230 commit 47e3536
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions fs/exfat/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,9 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)
loff_t pos = iocb->ki_pos;
loff_t valid_size;

if (unlikely(exfat_forced_shutdown(inode->i_sb)))
return -EIO;

inode_lock(inode);

valid_size = ei->valid_size;
Expand Down Expand Up @@ -635,6 +638,16 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)
return ret;
}

static ssize_t exfat_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
{
struct inode *inode = file_inode(iocb->ki_filp);

if (unlikely(exfat_forced_shutdown(inode->i_sb)))
return -EIO;

return generic_file_read_iter(iocb, iter);
}

static vm_fault_t exfat_page_mkwrite(struct vm_fault *vmf)
{
int err;
Expand Down Expand Up @@ -672,22 +685,34 @@ static const struct vm_operations_struct exfat_file_vm_ops = {

static int exfat_file_mmap(struct file *file, struct vm_area_struct *vma)
{
if (unlikely(exfat_forced_shutdown(file_inode(file)->i_sb)))
return -EIO;

file_accessed(file);
vma->vm_ops = &exfat_file_vm_ops;
return 0;
}

static ssize_t exfat_splice_read(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe, size_t len, unsigned int flags)
{
if (unlikely(exfat_forced_shutdown(file_inode(in)->i_sb)))
return -EIO;

return filemap_splice_read(in, ppos, pipe, len, flags);
}

const struct file_operations exfat_file_operations = {
.llseek = generic_file_llseek,
.read_iter = generic_file_read_iter,
.read_iter = exfat_file_read_iter,
.write_iter = exfat_file_write_iter,
.unlocked_ioctl = exfat_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = exfat_compat_ioctl,
#endif
.mmap = exfat_file_mmap,
.fsync = exfat_file_fsync,
.splice_read = filemap_splice_read,
.splice_read = exfat_splice_read,
.splice_write = iter_file_splice_write,
};

Expand Down

0 comments on commit 47e3536

Please sign in to comment.