#include "cifs_unicode.h"
 
 #define MAX_EA_VALUE_SIZE CIFSMaxBufSize
-#define CIFS_XATTR_CIFS_ACL "system.cifs_acl"
+#define CIFS_XATTR_CIFS_ACL "system.cifs_acl" /* DACL only */
+#define CIFS_XATTR_CIFS_NTSD "system.cifs_ntsd" /* owner plus DACL */
 #define CIFS_XATTR_ATTRIB "cifs.dosattrib"  /* full name: user.cifs.dosattrib */
 #define CIFS_XATTR_CREATETIME "cifs.creationtime"  /* user.cifs.creationtime */
 /*
  * confusing users and using the 20+ year old term 'cifs' when it is no longer
  * secure, replaced by SMB2 (then even more highly secure SMB3) many years ago
  */
-#define SMB3_XATTR_CIFS_ACL "system.smb3_acl"
+#define SMB3_XATTR_CIFS_ACL "system.smb3_acl" /* DACL only */
+#define SMB3_XATTR_CIFS_NTSD "system.smb3_ntsd" /* owner plus DACL */
 #define SMB3_XATTR_ATTRIB "smb3.dosattrib"  /* full name: user.smb3.dosattrib */
 #define SMB3_XATTR_CREATETIME "smb3.creationtime"  /* user.smb3.creationtime */
 /* BB need to add server (Samba e.g) support for security and trusted prefix */
 
-enum { XATTR_USER, XATTR_CIFS_ACL, XATTR_ACL_ACCESS, XATTR_ACL_DEFAULT };
+enum { XATTR_USER, XATTR_CIFS_ACL, XATTR_ACL_ACCESS, XATTR_ACL_DEFAULT,
+       XATTR_CIFS_NTSD };
+
+static int cifs_attrib_set(unsigned int xid, struct cifs_tcon *pTcon,
+                          struct inode *inode, char *full_path,
+                          const void *value, size_t size)
+{
+       ssize_t rc = -EOPNOTSUPP;
+       __u32 *pattrib = (__u32 *)value;
+       __u32 attrib;
+       FILE_BASIC_INFO info_buf;
+
+       if ((value == NULL) || (size != sizeof(__u32)))
+               return -ERANGE;
+
+       memset(&info_buf, 0, sizeof(info_buf));
+       attrib = *pattrib;
+       info_buf.Attributes = cpu_to_le32(attrib);
+       if (pTcon->ses->server->ops->set_file_info)
+               rc = pTcon->ses->server->ops->set_file_info(inode, full_path,
+                               &info_buf, xid);
+       if (rc == 0)
+               CIFS_I(inode)->cifsAttrs = attrib;
+
+       return rc;
+}
+
+static int cifs_creation_time_set(unsigned int xid, struct cifs_tcon *pTcon,
+                                 struct inode *inode, char *full_path,
+                                 const void *value, size_t size)
+{
+       ssize_t rc = -EOPNOTSUPP;
+       __u64 *pcreation_time = (__u64 *)value;
+       __u64 creation_time;
+       FILE_BASIC_INFO info_buf;
+
+       if ((value == NULL) || (size != sizeof(__u64)))
+               return -ERANGE;
+
+       memset(&info_buf, 0, sizeof(info_buf));
+       creation_time = *pcreation_time;
+       info_buf.CreationTime = cpu_to_le64(creation_time);
+       if (pTcon->ses->server->ops->set_file_info)
+               rc = pTcon->ses->server->ops->set_file_info(inode, full_path,
+                               &info_buf, xid);
+       if (rc == 0)
+               CIFS_I(inode)->createtime = creation_time;
+
+       return rc;
+}
 
 static int cifs_xattr_set(const struct xattr_handler *handler,
                          struct dentry *dentry, struct inode *inode,
 
        switch (handler->flags) {
        case XATTR_USER:
+               cifs_dbg(FYI, "%s:setting user xattr %s\n", __func__, name);
+               if ((strcmp(name, CIFS_XATTR_ATTRIB) == 0) ||
+                   (strcmp(name, SMB3_XATTR_ATTRIB) == 0)) {
+                       rc = cifs_attrib_set(xid, pTcon, inode, full_path,
+                                       value, size);
+                       if (rc == 0) /* force revalidate of the inode */
+                               CIFS_I(inode)->time = 0;
+                       break;
+               } else if ((strcmp(name, CIFS_XATTR_CREATETIME) == 0) ||
+                          (strcmp(name, SMB3_XATTR_CREATETIME) == 0)) {
+                       rc = cifs_creation_time_set(xid, pTcon, inode,
+                                       full_path, value, size);
+                       if (rc == 0) /* force revalidate of the inode */
+                               CIFS_I(inode)->time = 0;
+                       break;
+               }
+
                if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
                        goto out;
 
                                cifs_sb->local_nls, cifs_sb);
                break;
 
-       case XATTR_CIFS_ACL: {
+       case XATTR_CIFS_ACL:
+       case XATTR_CIFS_NTSD: {
                struct cifs_ntsd *pacl;
 
                if (!value)
                } else {
                        memcpy(pacl, value, size);
                        if (value &&
-                           pTcon->ses->server->ops->set_acl)
-                               rc = pTcon->ses->server->ops->set_acl(pacl,
-                                               size, inode,
-                                               full_path, CIFS_ACL_DACL);
-                       else
+                           pTcon->ses->server->ops->set_acl) {
+                               rc = 0;
+                               if (handler->flags == XATTR_CIFS_NTSD) {
+                                       /* set owner and DACL */
+                                       rc = pTcon->ses->server->ops->set_acl(
+                                                       pacl, size, inode,
+                                                       full_path,
+                                                       CIFS_ACL_OWNER);
+                               }
+                               if (rc == 0) {
+                                       /* set DACL */
+                                       rc = pTcon->ses->server->ops->set_acl(
+                                                       pacl, size, inode,
+                                                       full_path,
+                                                       CIFS_ACL_DACL);
+                               }
+                       } else {
                                rc = -EOPNOTSUPP;
+                       }
                        if (rc == 0) /* force revalidate of the inode */
                                CIFS_I(inode)->time = 0;
                        kfree(pacl);
                                  void *value, size_t size)
 {
        ssize_t rc;
-       __u64 * pcreatetime;
+       __u64 *pcreatetime;
 
        rc = cifs_revalidate_dentry_attr(dentry);
        if (rc)
                                full_path, name, value, size, cifs_sb);
                break;
 
-       case XATTR_CIFS_ACL: {
+       case XATTR_CIFS_ACL:
+       case XATTR_CIFS_NTSD: {
+               /* the whole ntsd is fetched regardless */
                u32 acllen;
                struct cifs_ntsd *pacl;
 
        .set = cifs_xattr_set,
 };
 
+static const struct xattr_handler cifs_cifs_ntsd_xattr_handler = {
+       .name = CIFS_XATTR_CIFS_NTSD,
+       .flags = XATTR_CIFS_NTSD,
+       .get = cifs_xattr_get,
+       .set = cifs_xattr_set,
+};
+
+/*
+ * Although this is just an alias for the above, need to move away from
+ * confusing users and using the 20 year old term 'cifs' when it is no
+ * longer secure and was replaced by SMB2/SMB3 a long time ago, and
+ * SMB3 and later are highly secure.
+ */
+static const struct xattr_handler smb3_ntsd_xattr_handler = {
+       .name = SMB3_XATTR_CIFS_NTSD,
+       .flags = XATTR_CIFS_NTSD,
+       .get = cifs_xattr_get,
+       .set = cifs_xattr_set,
+};
+
 static const struct xattr_handler cifs_posix_acl_access_xattr_handler = {
        .name = XATTR_NAME_POSIX_ACL_ACCESS,
        .flags = XATTR_ACL_ACCESS,
        &cifs_os2_xattr_handler,
        &cifs_cifs_acl_xattr_handler,
        &smb3_acl_xattr_handler, /* alias for above since avoiding "cifs" */
+       &cifs_cifs_ntsd_xattr_handler,
+       &smb3_ntsd_xattr_handler, /* alias for above since avoiding "cifs" */
        &cifs_posix_acl_access_xattr_handler,
        &cifs_posix_acl_default_xattr_handler,
        NULL