Skip to content

Commit bf782ad

Browse files
paliSteve French
authored andcommitted
cifs: Add a new xattr system.smb3_ntsd_sacl for getting or setting SACLs
Access to SACL part of SMB security descriptor is granted by SACL privilege which by default is accessible only for local administrator. But it can be granted to any other user by local GPO or AD. SACL access is not granted by DACL permissions and therefore is it possible that some user would not have access to DACLs of some file, but would have access to SACLs of all files. So it means that for accessing SACLs (either getting or setting) in some cases requires not touching or asking for DACLs. Currently Linux SMB client does not allow to get or set SACLs without touching DACLs. Which means that user without DACL access is not able to get or set SACLs even if it has access to SACLs. Fix this problem by introducing a new xattr "system.smb3_ntsd_sacl" for accessing only SACLs part of the security descriptor (therefore without DACLs and OWNER/GROUP). Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 764da2f commit bf782ad

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

fs/smb/client/xattr.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@
3131
* secure, replaced by SMB2 (then even more highly secure SMB3) many years ago
3232
*/
3333
#define SMB3_XATTR_CIFS_ACL "system.smb3_acl" /* DACL only */
34+
#define SMB3_XATTR_CIFS_NTSD_SACL "system.smb3_ntsd_sacl" /* SACL only */
3435
#define SMB3_XATTR_CIFS_NTSD "system.smb3_ntsd" /* owner plus DACL */
3536
#define SMB3_XATTR_CIFS_NTSD_FULL "system.smb3_ntsd_full" /* owner/DACL/SACL */
3637
#define SMB3_XATTR_ATTRIB "smb3.dosattrib" /* full name: user.smb3.dosattrib */
3738
#define SMB3_XATTR_CREATETIME "smb3.creationtime" /* user.smb3.creationtime */
3839
/* BB need to add server (Samba e.g) support for security and trusted prefix */
3940

4041
enum { XATTR_USER, XATTR_CIFS_ACL, XATTR_ACL_ACCESS, XATTR_ACL_DEFAULT,
42+
XATTR_CIFS_NTSD_SACL,
4143
XATTR_CIFS_NTSD, XATTR_CIFS_NTSD_FULL };
4244

4345
static int cifs_attrib_set(unsigned int xid, struct cifs_tcon *pTcon,
@@ -160,6 +162,7 @@ static int cifs_xattr_set(const struct xattr_handler *handler,
160162
break;
161163

162164
case XATTR_CIFS_ACL:
165+
case XATTR_CIFS_NTSD_SACL:
163166
case XATTR_CIFS_NTSD:
164167
case XATTR_CIFS_NTSD_FULL: {
165168
struct smb_ntsd *pacl;
@@ -187,6 +190,9 @@ static int cifs_xattr_set(const struct xattr_handler *handler,
187190
CIFS_ACL_GROUP |
188191
CIFS_ACL_DACL);
189192
break;
193+
case XATTR_CIFS_NTSD_SACL:
194+
aclflags = CIFS_ACL_SACL;
195+
break;
190196
case XATTR_CIFS_ACL:
191197
default:
192198
aclflags = CIFS_ACL_DACL;
@@ -308,6 +314,7 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
308314
break;
309315

310316
case XATTR_CIFS_ACL:
317+
case XATTR_CIFS_NTSD_SACL:
311318
case XATTR_CIFS_NTSD:
312319
case XATTR_CIFS_NTSD_FULL: {
313320
/*
@@ -327,6 +334,9 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
327334
case XATTR_CIFS_NTSD:
328335
extra_info = OWNER_SECINFO | GROUP_SECINFO | DACL_SECINFO;
329336
break;
337+
case XATTR_CIFS_NTSD_SACL:
338+
extra_info = SACL_SECINFO;
339+
break;
330340
case XATTR_CIFS_ACL:
331341
default:
332342
extra_info = DACL_SECINFO;
@@ -448,6 +458,13 @@ static const struct xattr_handler smb3_acl_xattr_handler = {
448458
.set = cifs_xattr_set,
449459
};
450460

461+
static const struct xattr_handler smb3_ntsd_sacl_xattr_handler = {
462+
.name = SMB3_XATTR_CIFS_NTSD_SACL,
463+
.flags = XATTR_CIFS_NTSD_SACL,
464+
.get = cifs_xattr_get,
465+
.set = cifs_xattr_set,
466+
};
467+
451468
static const struct xattr_handler cifs_cifs_ntsd_xattr_handler = {
452469
.name = CIFS_XATTR_CIFS_NTSD,
453470
.flags = XATTR_CIFS_NTSD,
@@ -493,6 +510,7 @@ const struct xattr_handler * const cifs_xattr_handlers[] = {
493510
&cifs_os2_xattr_handler,
494511
&cifs_cifs_acl_xattr_handler,
495512
&smb3_acl_xattr_handler, /* alias for above since avoiding "cifs" */
513+
&smb3_ntsd_sacl_xattr_handler,
496514
&cifs_cifs_ntsd_xattr_handler,
497515
&smb3_ntsd_xattr_handler, /* alias for above since avoiding "cifs" */
498516
&cifs_cifs_ntsd_full_xattr_handler,

0 commit comments

Comments
 (0)