aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
authorSteve French <stfrench@microsoft.com>2026-05-26 15:25:54 -0500
committerSteve French <stfrench@microsoft.com>2026-05-27 17:17:32 -0500
commitcbf23496153b89e6b32585d713e96118ca05109e (patch)
treeddd437b444f0cde3ea2b40c59f57a92a84989fab /fs
parent8b33e9007b2164bae9d4b6da860551992297b7e4 (diff)
downloadlinux-next-history-cbf23496153b89e6b32585d713e96118ca05109e.tar.gz
smb: client: fix chmod and chgrp with SMB3.1.1 POSIX Extensions
chmod and chgrp were being ignored when mouting with the SMB3.1.1 POSIX Extensions. Add support for chmod and chgrp when mounting with the SMB3.1.1 POSIX Extensions. Cc: stable@vger.kernel.org Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/smb/client/cifsacl.c18
-rw-r--r--fs/smb/client/inode.c3
2 files changed, 18 insertions, 3 deletions
diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
index 42a3115359dac..6b8626f075018 100644
--- a/fs/smb/client/cifsacl.c
+++ b/fs/smb/client/cifsacl.c
@@ -1468,7 +1468,14 @@ static int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *pnntsd,
goto chown_chgrp_exit;
}
id = from_kuid(&init_user_ns, uid);
- if (id_from_sid) {
+ if (posix) {
+ /* SMB3.1.1 POSIX: Unix Mapping owner SID S-1-22-1-<uid> */
+ nowner_sid_ptr->revision = 1;
+ nowner_sid_ptr->num_subauth = 2;
+ nowner_sid_ptr->authority[5] = 22;
+ nowner_sid_ptr->sub_auth[0] = cpu_to_le32(1);
+ nowner_sid_ptr->sub_auth[1] = cpu_to_le32(id);
+ } else if (id_from_sid) {
struct owner_sid *osid = (struct owner_sid *)nowner_sid_ptr;
/* Populate the user ownership fields S-1-5-88-1 */
osid->Revision = 1;
@@ -1496,7 +1503,14 @@ static int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *pnntsd,
goto chown_chgrp_exit;
}
id = from_kgid(&init_user_ns, gid);
- if (id_from_sid) {
+ if (posix) {
+ /* SMB3.1.1 POSIX: Unix Mapping group SID S-1-22-2-<gid> */
+ ngroup_sid_ptr->revision = 1;
+ ngroup_sid_ptr->num_subauth = 2;
+ ngroup_sid_ptr->authority[5] = 22;
+ ngroup_sid_ptr->sub_auth[0] = cpu_to_le32(2);
+ ngroup_sid_ptr->sub_auth[1] = cpu_to_le32(id);
+ } else if (id_from_sid) {
struct owner_sid *gsid = (struct owner_sid *)ngroup_sid_ptr;
/* Populate the group ownership fields S-1-5-88-2 */
gsid->Revision = 1;
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index 0af93e881608a..826d36ed13ec9 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -3376,7 +3376,8 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
if (attrs->ia_valid & ATTR_GID)
gid = attrs->ia_gid;
- if (sbflags & (CIFS_MOUNT_CIFS_ACL | CIFS_MOUNT_MODE_FROM_SID)) {
+ if ((sbflags & (CIFS_MOUNT_CIFS_ACL | CIFS_MOUNT_MODE_FROM_SID)) ||
+ cifs_sb_master_tcon(cifs_sb)->posix_extensions) {
if (uid_valid(uid) || gid_valid(gid)) {
mode = NO_CHANGE_64;
rc = id_mode_to_cifs_acl(inode, full_path, &mode,