Skip to contentSkip to conversation

smb: client: fix chmod(2) regression with ATTR_READONLY

PATCH In review Paulo Alcantara 2 participants 2 messages Feb 16, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smb: client: fix chmod(2) regression with ATTR_READONLY

When the user sets a file or directory as read-only (e.g. ~S_IWUGO), the client will set the ATTR_READONLY attribute by sending an SMB2_SET_INFO request to the server in cifs_setattr_{,nounix}(), but cifsInodeInfo::cifsAttrs will be left unchanged as the client will only update the new file attributes in the next call to {smb311_posix,cifs}_get_inode_info() with the new metadata filled in @data parameter.

Commit a18280e7fdea ("smb: cilent: set reparse mount points as automounts") mistakenly removed the @data NULL check when calling is_inode_cache_good(), which broke the above case as the new ATTR_READONLY attribute would end up not being updated on files with a read lease.

Fix this by updating the inode whenever we have cached metadata in @data parameter.

Fixes a18280e7fdea ("smb: cilent: set reparse mount points as automounts")
---
 fs/smb/client/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/inode.c +2 -2
index 214240612549..616149c7f0a5 100644
@@ -1421,7 +1421,7 @@ int cifs_get_inode_info(struct inode **inode,
 	struct cifs_fattr fattr = {};
 	int rc;
 
-	if (is_inode_cache_good(*inode)) {
+	if (!data && is_inode_cache_good(*inode)) {
 		cifs_dbg(FYI, "No need to revalidate cached inode sizes\n");
 		return 0;
 	}
@@ -1520,7 +1520,7 @@ int smb311_posix_get_inode_info(struct inode **inode,
 	struct cifs_fattr fattr = {};
 	int rc;
 
-	if (is_inode_cache_good(*inode)) {
+	if (!data && is_inode_cache_good(*inode)) {
 		cifs_dbg(FYI, "No need to revalidate cached inode sizes\n");
 		return 0;
 	}
Signature · 1 line
2.48.1
#1 lore raw

tentatively merged into cifs-2.6.git for-next pending more testing and review

Quoted 51 lines · Paulo Alcantara

When the user sets a file or directory as read-only (e.g. ~S_IWUGO), the client will set the ATTR_READONLY attribute by sending an SMB2_SET_INFO request to the server in cifs_setattr_{,nounix}(), but cifsInodeInfo::cifsAttrs will be left unchanged as the client will only update the new file attributes in the next call to {smb311_posix,cifs}_get_inode_info() with the new metadata filled in @data parameter.

Commit a18280e7fdea ("smb: cilent: set reparse mount points as automounts") mistakenly removed the @data NULL check when calling is_inode_cache_good(), which broke the above case as the new ATTR_READONLY attribute would end up not being updated on files with a read lease.

Fix this by updating the inode whenever we have cached metadata in @data parameter.

Fixes a18280e7fdea ("smb: cilent: set reparse mount points as automounts")
---
 fs/smb/client/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/inode.c +2 -3
index 214240612549..616149c7f0a5 100644
@@ -1421,7 +1421,7 @@ int cifs_get_inode_info(struct inode **inode,
        struct cifs_fattr fattr = {};
        int rc;
 
-       if (is_inode_cache_good(*inode)) {
+       if (!data && is_inode_cache_good(*inode)) {
                cifs_dbg(FYI, "No need to revalidate cached inode sizes\n");
                return 0;
        }
@@ -1520,7 +1520,7 @@ int smb311_posix_get_inode_info(struct inode **inode,
        struct cifs_fattr fattr = {};
        int rc;
 
-       if (is_inode_cache_good(*inode)) {
+       if (!data && is_inode_cache_good(*inode)) {
                cifs_dbg(FYI, "No need to revalidate cached inode sizes\n");
                return 0;
        }
--

2.48.1

Signature · 3 lines
Thanks,

Steve