Skip to content

Commit 08bc035

Browse files
jtlaytonsmfrench
authored andcommitted
cifs: revalidate mapping prior to satisfying read_iter request with cache=loose
Before satisfying a read with cache=loose, we should always check that the pagecache is valid before allowing a read to be satisfied out of it. Reported-by: Tetsuo Handa <[email protected]> Signed-off-by: Jeff Layton <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent a1d0b84 commit 08bc035

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

fs/cifs/cifsfs.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,19 @@ cifs_do_mount(struct file_system_type *fs_type,
725725
goto out;
726726
}
727727

728+
static ssize_t
729+
cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter)
730+
{
731+
ssize_t rc;
732+
struct inode *inode = file_inode(iocb->ki_filp);
733+
734+
rc = cifs_revalidate_mapping(inode);
735+
if (rc)
736+
return rc;
737+
738+
return generic_file_read_iter(iocb, iter);
739+
}
740+
728741
static ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
729742
{
730743
struct inode *inode = file_inode(iocb->ki_filp);
@@ -881,7 +894,7 @@ const struct inode_operations cifs_symlink_inode_ops = {
881894
const struct file_operations cifs_file_ops = {
882895
.read = new_sync_read,
883896
.write = new_sync_write,
884-
.read_iter = generic_file_read_iter,
897+
.read_iter = cifs_loose_read_iter,
885898
.write_iter = cifs_file_write_iter,
886899
.open = cifs_open,
887900
.release = cifs_close,
@@ -939,7 +952,7 @@ const struct file_operations cifs_file_direct_ops = {
939952
const struct file_operations cifs_file_nobrl_ops = {
940953
.read = new_sync_read,
941954
.write = new_sync_write,
942-
.read_iter = generic_file_read_iter,
955+
.read_iter = cifs_loose_read_iter,
943956
.write_iter = cifs_file_write_iter,
944957
.open = cifs_open,
945958
.release = cifs_close,

0 commit comments

Comments
 (0)