diff options
author | Bharath SM <bharathsm@microsoft.com> | 2024-02-29 20:39:52 +0300 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2024-03-11 03:33:53 +0300 |
commit | e4b61f3b1c67f5068590965f64ea6e8d5d5bd961 (patch) | |
tree | bcf7ebb2ac00bf0f4aaa79472fdb823f96b94e58 /fs/smb/client/readdir.c | |
parent | e8f897f4afef0031fe618a8e94127a0934896aba (diff) | |
download | linux-e4b61f3b1c67f5068590965f64ea6e8d5d5bd961.tar.xz |
cifs: prevent updating file size from server if we have a read/write lease
In cases of large directories, the readdir operation may span multiple
round trips to retrieve contents. This introduces a potential race
condition in case of concurrent write and readdir operations. If the
readdir operation initiates before a write has been processed by the
server, it may update the file size attribute to an older value.
Address this issue by avoiding file size updates from readdir when we
have read/write lease.
Scenario:
1) process1: open dir xyz
2) process1: readdir instance 1 on xyz
3) process2: create file.txt for write
4) process2: write x bytes to file.txt
5) process2: close file.txt
6) process2: open file.txt for read
7) process1: readdir 2 - overwrites file.txt inode size to 0
8) process2: read contents of file.txt - bug, short read with 0 bytes
Cc: stable@vger.kernel.org
Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Bharath SM <bharathsm@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/smb/client/readdir.c')
-rw-r--r-- | fs/smb/client/readdir.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/smb/client/readdir.c b/fs/smb/client/readdir.c index b520eea7bfce..132ae7d884a9 100644 --- a/fs/smb/client/readdir.c +++ b/fs/smb/client/readdir.c @@ -148,7 +148,7 @@ retry: rc = -ESTALE; } } - if (!rc && !cifs_fattr_to_inode(inode, fattr)) { + if (!rc && !cifs_fattr_to_inode(inode, fattr, true)) { dput(dentry); return; } |