Skip to content

Commit 8b19dfb

Browse files
paliSteve French
authored andcommitted
cifs: Fix getting and setting SACLs over SMB1
SMB1 callback get_cifs_acl_by_fid() currently ignores its last argument and therefore ignores request for SACL_SECINFO. Fix this issue by correctly propagating info argument from get_cifs_acl() and get_cifs_acl_by_fid() to CIFSSMBGetCIFSACL() function and pass SACL_SECINFO when requested. For accessing SACLs it is needed to open object with SYSTEM_SECURITY access. Pass this flag when trying to get or set SACLs. Same logic is in the SMB2+ code path. This change fixes getting and setting of "system.cifs_ntsd_full" and "system.smb3_ntsd_full" xattrs over SMB1 as currently it silentely ignored SACL part of passed xattr buffer. Fixes: 3970acf ("SMB3: Add support for getting and setting SACLs") Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 25f6184 commit 8b19dfb

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

fs/smb/client/cifsacl.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,7 @@ static int build_sec_desc(struct smb_ntsd *pntsd, struct smb_ntsd *pnntsd,
13951395
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
13961396
struct smb_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
13971397
const struct cifs_fid *cifsfid, u32 *pacllen,
1398-
u32 __maybe_unused unused)
1398+
u32 info)
13991399
{
14001400
struct smb_ntsd *pntsd = NULL;
14011401
unsigned int xid;
@@ -1407,7 +1407,7 @@ struct smb_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
14071407

14081408
xid = get_xid();
14091409
rc = CIFSSMBGetCIFSACL(xid, tlink_tcon(tlink), cifsfid->netfid, &pntsd,
1410-
pacllen);
1410+
pacllen, info);
14111411
free_xid(xid);
14121412

14131413
cifs_put_tlink(tlink);
@@ -1419,7 +1419,7 @@ struct smb_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
14191419
}
14201420

14211421
static struct smb_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
1422-
const char *path, u32 *pacllen)
1422+
const char *path, u32 *pacllen, u32 info)
14231423
{
14241424
struct smb_ntsd *pntsd = NULL;
14251425
int oplock = 0;
@@ -1446,9 +1446,12 @@ static struct smb_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
14461446
.fid = &fid,
14471447
};
14481448

1449+
if (info & SACL_SECINFO)
1450+
oparms.desired_access |= SYSTEM_SECURITY;
1451+
14491452
rc = CIFS_open(xid, &oparms, &oplock, NULL);
14501453
if (!rc) {
1451-
rc = CIFSSMBGetCIFSACL(xid, tcon, fid.netfid, &pntsd, pacllen);
1454+
rc = CIFSSMBGetCIFSACL(xid, tcon, fid.netfid, &pntsd, pacllen, info);
14521455
CIFSSMBClose(xid, tcon, fid.netfid);
14531456
}
14541457

@@ -1472,7 +1475,7 @@ struct smb_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb,
14721475
if (inode)
14731476
open_file = find_readable_file(CIFS_I(inode), true);
14741477
if (!open_file)
1475-
return get_cifs_acl_by_path(cifs_sb, path, pacllen);
1478+
return get_cifs_acl_by_path(cifs_sb, path, pacllen, info);
14761479

14771480
pntsd = get_cifs_acl_by_fid(cifs_sb, &open_file->fid, pacllen, info);
14781481
cifsFileInfo_put(open_file);
@@ -1485,7 +1488,7 @@ int set_cifs_acl(struct smb_ntsd *pnntsd, __u32 acllen,
14851488
{
14861489
int oplock = 0;
14871490
unsigned int xid;
1488-
int rc, access_flags;
1491+
int rc, access_flags = 0;
14891492
struct cifs_tcon *tcon;
14901493
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
14911494
struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
@@ -1498,10 +1501,12 @@ int set_cifs_acl(struct smb_ntsd *pnntsd, __u32 acllen,
14981501
tcon = tlink_tcon(tlink);
14991502
xid = get_xid();
15001503

1501-
if (aclflag == CIFS_ACL_OWNER || aclflag == CIFS_ACL_GROUP)
1502-
access_flags = WRITE_OWNER;
1503-
else
1504-
access_flags = WRITE_DAC;
1504+
if (aclflag & CIFS_ACL_OWNER || aclflag & CIFS_ACL_GROUP)
1505+
access_flags |= WRITE_OWNER;
1506+
if (aclflag & CIFS_ACL_SACL)
1507+
access_flags |= SYSTEM_SECURITY;
1508+
if (aclflag & CIFS_ACL_DACL)
1509+
access_flags |= WRITE_DAC;
15051510

15061511
oparms = (struct cifs_open_parms) {
15071512
.tcon = tcon,

fs/smb/client/cifsproto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ extern int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,
557557
const struct nls_table *nls_codepage,
558558
struct cifs_sb_info *cifs_sb);
559559
extern int CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon,
560-
__u16 fid, struct smb_ntsd **acl_inf, __u32 *buflen);
560+
__u16 fid, struct smb_ntsd **acl_inf, __u32 *buflen, __u32 info);
561561
extern int CIFSSMBSetCIFSACL(const unsigned int, struct cifs_tcon *, __u16,
562562
struct smb_ntsd *pntsd, __u32 len, int aclflag);
563563
extern int cifs_do_get_acl(const unsigned int xid, struct cifs_tcon *tcon,

fs/smb/client/cifssmb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3369,7 +3369,7 @@ validate_ntransact(char *buf, char **ppparm, char **ppdata,
33693369
/* Get Security Descriptor (by handle) from remote server for a file or dir */
33703370
int
33713371
CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon, __u16 fid,
3372-
struct smb_ntsd **acl_inf, __u32 *pbuflen)
3372+
struct smb_ntsd **acl_inf, __u32 *pbuflen, __u32 info)
33733373
{
33743374
int rc = 0;
33753375
int buf_type = 0;
@@ -3392,7 +3392,7 @@ CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon, __u16 fid,
33923392
pSMB->MaxSetupCount = 0;
33933393
pSMB->Fid = fid; /* file handle always le */
33943394
pSMB->AclFlags = cpu_to_le32(CIFS_ACL_OWNER | CIFS_ACL_GROUP |
3395-
CIFS_ACL_DACL);
3395+
CIFS_ACL_DACL | info);
33963396
pSMB->ByteCount = cpu_to_le16(11); /* 3 bytes pad + 8 bytes parm */
33973397
inc_rfc1001_len(pSMB, 11);
33983398
iov[0].iov_base = (char *)pSMB;

0 commit comments

Comments
 (0)