3434#define MAX_EA_VALUE_SIZE CIFSMaxBufSize
3535#define CIFS_XATTR_CIFS_ACL "system.cifs_acl" /* DACL only */
3636#define CIFS_XATTR_CIFS_NTSD "system.cifs_ntsd" /* owner plus DACL */
37+ #define CIFS_XATTR_CIFS_NTSD_FULL "system.cifs_ntsd_full" /* owner/DACL/SACL */
3738#define CIFS_XATTR_ATTRIB "cifs.dosattrib" /* full name: user.cifs.dosattrib */
3839#define CIFS_XATTR_CREATETIME "cifs.creationtime" /* user.cifs.creationtime */
3940/*
4344 */
4445#define SMB3_XATTR_CIFS_ACL "system.smb3_acl" /* DACL only */
4546#define SMB3_XATTR_CIFS_NTSD "system.smb3_ntsd" /* owner plus DACL */
47+ #define SMB3_XATTR_CIFS_NTSD_FULL "system.smb3_ntsd_full" /* owner/DACL/SACL */
4648#define SMB3_XATTR_ATTRIB "smb3.dosattrib" /* full name: user.smb3.dosattrib */
4749#define SMB3_XATTR_CREATETIME "smb3.creationtime" /* user.smb3.creationtime */
4850/* BB need to add server (Samba e.g) support for security and trusted prefix */
4951
5052enum { XATTR_USER , XATTR_CIFS_ACL , XATTR_ACL_ACCESS , XATTR_ACL_DEFAULT ,
51- XATTR_CIFS_NTSD };
53+ XATTR_CIFS_NTSD , XATTR_CIFS_NTSD_FULL };
5254
5355static int cifs_attrib_set (unsigned int xid , struct cifs_tcon * pTcon ,
5456 struct inode * inode , char * full_path ,
@@ -164,7 +166,8 @@ static int cifs_xattr_set(const struct xattr_handler *handler,
164166 break ;
165167
166168 case XATTR_CIFS_ACL :
167- case XATTR_CIFS_NTSD : {
169+ case XATTR_CIFS_NTSD :
170+ case XATTR_CIFS_NTSD_FULL : {
168171 struct cifs_ntsd * pacl ;
169172
170173 if (!value )
@@ -174,23 +177,27 @@ static int cifs_xattr_set(const struct xattr_handler *handler,
174177 rc = - ENOMEM ;
175178 } else {
176179 memcpy (pacl , value , size );
177- if (value &&
178- pTcon -> ses -> server -> ops -> set_acl ) {
180+ if (pTcon -> ses -> server -> ops -> set_acl ) {
181+ int aclflags = 0 ;
179182 rc = 0 ;
180- if (handler -> flags == XATTR_CIFS_NTSD ) {
181- /* set owner and DACL */
182- rc = pTcon -> ses -> server -> ops -> set_acl (
183- pacl , size , inode ,
184- full_path ,
185- CIFS_ACL_OWNER );
186- }
187- if (rc == 0 ) {
188- /* set DACL */
189- rc = pTcon -> ses -> server -> ops -> set_acl (
190- pacl , size , inode ,
191- full_path ,
192- CIFS_ACL_DACL );
183+
184+ switch (handler -> flags ) {
185+ case XATTR_CIFS_NTSD_FULL :
186+ aclflags = (CIFS_ACL_OWNER |
187+ CIFS_ACL_DACL |
188+ CIFS_ACL_SACL );
189+ break ;
190+ case XATTR_CIFS_NTSD :
191+ aclflags = (CIFS_ACL_OWNER |
192+ CIFS_ACL_DACL );
193+ break ;
194+ case XATTR_CIFS_ACL :
195+ default :
196+ aclflags = CIFS_ACL_DACL ;
193197 }
198+
199+ rc = pTcon -> ses -> server -> ops -> set_acl (pacl ,
200+ size , inode , full_path , aclflags );
194201 } else {
195202 rc = - EOPNOTSUPP ;
196203 }
@@ -327,16 +334,27 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
327334 break ;
328335
329336 case XATTR_CIFS_ACL :
330- case XATTR_CIFS_NTSD : {
331- /* the whole ntsd is fetched regardless */
332- u32 acllen ;
337+ case XATTR_CIFS_NTSD :
338+ case XATTR_CIFS_NTSD_FULL : {
339+ /*
340+ * fetch owner, DACL, and SACL if asked for full descriptor,
341+ * fetch owner and DACL otherwise
342+ */
343+ u32 acllen , additional_info = 0 ;
333344 struct cifs_ntsd * pacl ;
334345
335346 if (pTcon -> ses -> server -> ops -> get_acl == NULL )
336347 goto out ; /* rc already EOPNOTSUPP */
337348
349+ if (handler -> flags == XATTR_CIFS_NTSD_FULL ) {
350+ additional_info = OWNER_SECINFO | GROUP_SECINFO |
351+ DACL_SECINFO | SACL_SECINFO ;
352+ } else {
353+ additional_info = OWNER_SECINFO | GROUP_SECINFO |
354+ DACL_SECINFO ;
355+ }
338356 pacl = pTcon -> ses -> server -> ops -> get_acl (cifs_sb ,
339- inode , full_path , & acllen );
357+ inode , full_path , & acllen , additional_info );
340358 if (IS_ERR (pacl )) {
341359 rc = PTR_ERR (pacl );
342360 cifs_dbg (VFS , "%s: error %zd getting sec desc\n" ,
@@ -486,6 +504,27 @@ static const struct xattr_handler smb3_ntsd_xattr_handler = {
486504 .set = cifs_xattr_set ,
487505};
488506
507+ static const struct xattr_handler cifs_cifs_ntsd_full_xattr_handler = {
508+ .name = CIFS_XATTR_CIFS_NTSD_FULL ,
509+ .flags = XATTR_CIFS_NTSD_FULL ,
510+ .get = cifs_xattr_get ,
511+ .set = cifs_xattr_set ,
512+ };
513+
514+ /*
515+ * Although this is just an alias for the above, need to move away from
516+ * confusing users and using the 20 year old term 'cifs' when it is no
517+ * longer secure and was replaced by SMB2/SMB3 a long time ago, and
518+ * SMB3 and later are highly secure.
519+ */
520+ static const struct xattr_handler smb3_ntsd_full_xattr_handler = {
521+ .name = SMB3_XATTR_CIFS_NTSD_FULL ,
522+ .flags = XATTR_CIFS_NTSD_FULL ,
523+ .get = cifs_xattr_get ,
524+ .set = cifs_xattr_set ,
525+ };
526+
527+
489528static const struct xattr_handler cifs_posix_acl_access_xattr_handler = {
490529 .name = XATTR_NAME_POSIX_ACL_ACCESS ,
491530 .flags = XATTR_ACL_ACCESS ,
@@ -507,6 +546,8 @@ const struct xattr_handler *cifs_xattr_handlers[] = {
507546 & smb3_acl_xattr_handler , /* alias for above since avoiding "cifs" */
508547 & cifs_cifs_ntsd_xattr_handler ,
509548 & smb3_ntsd_xattr_handler , /* alias for above since avoiding "cifs" */
549+ & cifs_cifs_ntsd_full_xattr_handler ,
550+ & smb3_ntsd_full_xattr_handler , /* alias for above since avoiding "cifs" */
510551 & cifs_posix_acl_access_xattr_handler ,
511552 & cifs_posix_acl_default_xattr_handler ,
512553 NULL
0 commit comments