Skip to content

Commit b1a37df

Browse files
paliSteve French
authored andcommitted
cifs: Add a new xattr system.smb3_ntsd_owner for getting or setting owner
Changing owner is controlled by DACL permission WRITE_OWNER. Changing DACL itself is controlled by DACL permisssion WRITE_DAC. Owner of the file has implicit WRITE_DAC permission even when it is not explicitly granted for owner by DACL. Reading DACL or owner is controlled only by one permission READ_CONTROL. WRITE_OWNER permission can be bypassed by the SeTakeOwnershipPrivilege, which is by default available for local administrators. So if the local administrator wants to access some file to which does not have access, it is required to first change owner to ourself and then change DACL permissions. Currently Linux SMB client does not support this because client does not provide a way to change owner without touching DACL permissions. Fix this problem by introducing a new xattr "system.smb3_ntsd_owner" for setting/changing only owner part of the security descriptor. Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent bf782ad commit b1a37df

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

fs/smb/client/xattr.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@
3232
*/
3333
#define SMB3_XATTR_CIFS_ACL "system.smb3_acl" /* DACL only */
3434
#define SMB3_XATTR_CIFS_NTSD_SACL "system.smb3_ntsd_sacl" /* SACL only */
35+
#define SMB3_XATTR_CIFS_NTSD_OWNER "system.smb3_ntsd_owner" /* owner only */
3536
#define SMB3_XATTR_CIFS_NTSD "system.smb3_ntsd" /* owner plus DACL */
3637
#define SMB3_XATTR_CIFS_NTSD_FULL "system.smb3_ntsd_full" /* owner/DACL/SACL */
3738
#define SMB3_XATTR_ATTRIB "smb3.dosattrib" /* full name: user.smb3.dosattrib */
3839
#define SMB3_XATTR_CREATETIME "smb3.creationtime" /* user.smb3.creationtime */
3940
/* BB need to add server (Samba e.g) support for security and trusted prefix */
4041

4142
enum { XATTR_USER, XATTR_CIFS_ACL, XATTR_ACL_ACCESS, XATTR_ACL_DEFAULT,
42-
XATTR_CIFS_NTSD_SACL,
43+
XATTR_CIFS_NTSD_SACL, XATTR_CIFS_NTSD_OWNER,
4344
XATTR_CIFS_NTSD, XATTR_CIFS_NTSD_FULL };
4445

4546
static int cifs_attrib_set(unsigned int xid, struct cifs_tcon *pTcon,
@@ -163,6 +164,7 @@ static int cifs_xattr_set(const struct xattr_handler *handler,
163164

164165
case XATTR_CIFS_ACL:
165166
case XATTR_CIFS_NTSD_SACL:
167+
case XATTR_CIFS_NTSD_OWNER:
166168
case XATTR_CIFS_NTSD:
167169
case XATTR_CIFS_NTSD_FULL: {
168170
struct smb_ntsd *pacl;
@@ -190,6 +192,10 @@ static int cifs_xattr_set(const struct xattr_handler *handler,
190192
CIFS_ACL_GROUP |
191193
CIFS_ACL_DACL);
192194
break;
195+
case XATTR_CIFS_NTSD_OWNER:
196+
aclflags = (CIFS_ACL_OWNER |
197+
CIFS_ACL_GROUP);
198+
break;
193199
case XATTR_CIFS_NTSD_SACL:
194200
aclflags = CIFS_ACL_SACL;
195201
break;
@@ -315,6 +321,7 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
315321

316322
case XATTR_CIFS_ACL:
317323
case XATTR_CIFS_NTSD_SACL:
324+
case XATTR_CIFS_NTSD_OWNER:
318325
case XATTR_CIFS_NTSD:
319326
case XATTR_CIFS_NTSD_FULL: {
320327
/*
@@ -334,6 +341,9 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
334341
case XATTR_CIFS_NTSD:
335342
extra_info = OWNER_SECINFO | GROUP_SECINFO | DACL_SECINFO;
336343
break;
344+
case XATTR_CIFS_NTSD_OWNER:
345+
extra_info = OWNER_SECINFO | GROUP_SECINFO;
346+
break;
337347
case XATTR_CIFS_NTSD_SACL:
338348
extra_info = SACL_SECINFO;
339349
break;
@@ -465,6 +475,13 @@ static const struct xattr_handler smb3_ntsd_sacl_xattr_handler = {
465475
.set = cifs_xattr_set,
466476
};
467477

478+
static const struct xattr_handler smb3_ntsd_owner_xattr_handler = {
479+
.name = SMB3_XATTR_CIFS_NTSD_OWNER,
480+
.flags = XATTR_CIFS_NTSD_OWNER,
481+
.get = cifs_xattr_get,
482+
.set = cifs_xattr_set,
483+
};
484+
468485
static const struct xattr_handler cifs_cifs_ntsd_xattr_handler = {
469486
.name = CIFS_XATTR_CIFS_NTSD,
470487
.flags = XATTR_CIFS_NTSD,
@@ -511,6 +528,7 @@ const struct xattr_handler * const cifs_xattr_handlers[] = {
511528
&cifs_cifs_acl_xattr_handler,
512529
&smb3_acl_xattr_handler, /* alias for above since avoiding "cifs" */
513530
&smb3_ntsd_sacl_xattr_handler,
531+
&smb3_ntsd_owner_xattr_handler,
514532
&cifs_cifs_ntsd_xattr_handler,
515533
&smb3_ntsd_xattr_handler, /* alias for above since avoiding "cifs" */
516534
&cifs_cifs_ntsd_full_xattr_handler,

0 commit comments

Comments
 (0)