]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cifs: Fix getting DACL-only xattr system.cifs_acl and system.smb3_acl
authorPali Rohár <pali@kernel.org>
Mon, 14 Oct 2024 11:47:04 +0000 (13:47 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 May 2025 09:12:26 +0000 (11:12 +0200)
[ Upstream commit ad9364a6835c45c52f47587ffbe0577bb7cd4c5b ]

Currently ->get_acl() callback always create request for OWNER, GROUP and
DACL, even when only DACLs was requested by user. Change API callback to
request only information for which the caller asked. Therefore when only
DACLs requested, then SMB client will prepare and send DACL-only request.

This change fixes retrieving of "system.cifs_acl" and "system.smb3_acl"
xattrs to contain only DACL structure as documented.

Note that setting/changing of "system.cifs_acl" and "system.smb3_acl"
xattrs already takes only DACL structure and ignores all other fields.

Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/smb/client/cifsacl.c
fs/smb/client/cifssmb.c
fs/smb/client/smb2pdu.c
fs/smb/client/xattr.c

index f9d577f2d59bb08498b9a2d24c47590ffad7727a..63b3b1290bed214e04f005d210204382396848df 100644 (file)
@@ -1565,7 +1565,7 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
        int rc = 0;
        struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
        struct smb_version_operations *ops;
-       const u32 info = 0;
+       const u32 info = OWNER_SECINFO | GROUP_SECINFO | DACL_SECINFO;
 
        cifs_dbg(NOISY, "converting ACL to mode for %s\n", path);
 
@@ -1619,7 +1619,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,
        struct tcon_link *tlink;
        struct smb_version_operations *ops;
        bool mode_from_sid, id_from_sid;
-       const u32 info = 0;
+       const u32 info = OWNER_SECINFO | GROUP_SECINFO | DACL_SECINFO;
        bool posix;
 
        tlink = cifs_sb_tlink(cifs_sb);
index c2abe79f0dd3bee9eced536328bb5121a55ccb6e..e90811f321944f832e45cb035ef9832f123160d9 100644 (file)
@@ -3416,8 +3416,7 @@ CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon, __u16 fid,
        /* BB TEST with big acls that might need to be e.g. larger than 16K */
        pSMB->MaxSetupCount = 0;
        pSMB->Fid = fid; /* file handle always le */
-       pSMB->AclFlags = cpu_to_le32(CIFS_ACL_OWNER | CIFS_ACL_GROUP |
-                                    CIFS_ACL_DACL | info);
+       pSMB->AclFlags = cpu_to_le32(info);
        pSMB->ByteCount = cpu_to_le16(11); /* 3 bytes pad + 8 bytes parm */
        inc_rfc1001_len(pSMB, 11);
        iov[0].iov_base = (char *)pSMB;
index ed3ffcb80aef0e9ca27539b2571f13aa2c317b49..d080c777906b41ed572b8506005e94f27baf9e49 100644 (file)
@@ -3910,12 +3910,10 @@ SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
               u64 persistent_fid, u64 volatile_fid,
               void **data, u32 *plen, u32 extra_info)
 {
-       __u32 additional_info = OWNER_SECINFO | GROUP_SECINFO | DACL_SECINFO |
-                               extra_info;
        *plen = 0;
 
        return query_info(xid, tcon, persistent_fid, volatile_fid,
-                         0, SMB2_O_INFO_SECURITY, additional_info,
+                         0, SMB2_O_INFO_SECURITY, extra_info,
                          SMB2_MAX_BUFFER_SIZE, MIN_SEC_DESC_LEN, data, plen);
 }
 
index 58a584f0b27e9150c9a882fc3438a2aa34b5bf1d..7d49f38f01f3e704f316f8500b11d0b673e2f60b 100644 (file)
@@ -320,10 +320,17 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
                if (pTcon->ses->server->ops->get_acl == NULL)
                        goto out; /* rc already EOPNOTSUPP */
 
-               if (handler->flags == XATTR_CIFS_NTSD_FULL) {
-                       extra_info = SACL_SECINFO;
-               } else {
-                       extra_info = 0;
+               switch (handler->flags) {
+               case XATTR_CIFS_NTSD_FULL:
+                       extra_info = OWNER_SECINFO | GROUP_SECINFO | DACL_SECINFO | SACL_SECINFO;
+                       break;
+               case XATTR_CIFS_NTSD:
+                       extra_info = OWNER_SECINFO | GROUP_SECINFO | DACL_SECINFO;
+                       break;
+               case XATTR_CIFS_ACL:
+               default:
+                       extra_info = DACL_SECINFO;
+                       break;
                }
                pacl = pTcon->ses->server->ops->get_acl(cifs_sb,
                                inode, full_path, &acllen, extra_info);