SMB3.1.1: Fix ids returned in POSIX query dir
authorSteve French <stfrench@microsoft.com>
Tue, 20 Oct 2020 07:02:02 +0000 (02:02 -0500)
committerSteve French <stfrench@microsoft.com>
Tue, 20 Oct 2020 16:51:24 +0000 (11:51 -0500)
We were setting the uid/gid to the default in each dir entry
in the parsing of the POSIX query dir response, rather
than attempting to map the user and group SIDs returned by
the server to well known SIDs (or upcall if not found).

CC: Stable <stable@vger.kernel.org>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/cifsacl.c
fs/cifs/cifsproto.h
fs/cifs/readdir.c

index fcff14ef1c701bcc2a1c305f2670a150bad39df0..23b21e9436528d317f2e125a2ee7d971cb86f2ec 100644 (file)
@@ -338,7 +338,7 @@ invalidate_key:
        goto out_key_put;
 }
 
-static int
+int
 sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
                struct cifs_fattr *fattr, uint sidtype)
 {
@@ -359,7 +359,8 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
                return -EIO;
        }
 
-       if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL) {
+       if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL) ||
+           (cifs_sb_master_tcon(cifs_sb)->posix_extensions)) {
                uint32_t unix_id;
                bool is_group;
 
index bb68cbf8107408a8f8f12d6a5e530cbe14336916..24c6f36177bac396e9271f13f5a250fbec68f641 100644 (file)
@@ -209,6 +209,8 @@ extern int cifs_set_file_info(struct inode *inode, struct iattr *attrs,
 extern int cifs_rename_pending_delete(const char *full_path,
                                      struct dentry *dentry,
                                      const unsigned int xid);
+extern int sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
+                               struct cifs_fattr *fattr, uint sidtype);
 extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb,
                              struct cifs_fattr *fattr, struct inode *inode,
                              bool get_mode_from_special_sid,
index 31a18aae5e649e0d9adeffbb661f378211227264..5abf1ea21abefba8073ec2cb1adf0fe1434dae5f 100644 (file)
@@ -267,9 +267,8 @@ cifs_posix_to_fattr(struct cifs_fattr *fattr, struct smb2_posix_info *info,
        if (reparse_file_needs_reval(fattr))
                fattr->cf_flags |= CIFS_FATTR_NEED_REVAL;
 
-       /* TODO map SIDs */
-       fattr->cf_uid = cifs_sb->mnt_uid;
-       fattr->cf_gid = cifs_sb->mnt_gid;
+       sid_to_id(cifs_sb, &parsed.owner, fattr, SIDOWNER);
+       sid_to_id(cifs_sb, &parsed.group, fattr, SIDGROUP);
 }
 
 static void __dir_info_to_fattr(struct cifs_fattr *fattr, const void *info)