]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 09:07:10 +0000 (10:07 +0100)
commit 9934430e2178d5164eb1ac91a9b092f9e7e64745 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/cifs/cifsacl.c
fs/cifs/cifsproto.h
fs/cifs/readdir.c

index 6025d7fc7bbfd11f13b57174d2f1af149c2f200f..d0658891b0a6d0c6cf5c5c770f236b76b2084d90 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 7a836ec0438e810ca3b39ea2e57960c30e124833..f4751cb391238e84bd8694dcb5dec4f88a1101de 100644 (file)
@@ -208,6 +208,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 6df0922e7e304266fac709bd43546b8ab6da3de5..709fb53e9fee1f416e3331c1e5fe8aa6ea6b2781 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)