Skip to content

Commit 42eacf9

Browse files
committed
[CIFS] Fix cifsacl mounts over smb2 to not call cifs
When mounting with smb2/smb3 (e.g. vers=2.1) and cifsacl mount option, it was trying to get the mode by querying the acl over the cifs rather than smb2 protocol. This patch makes that protocol independent and makes cifsacl smb2 mounts return a more intuitive operation not supported error (until we add a worker function for smb2_get_acl). Note that a previous patch fixed getxattr/setxattr for the CIFSACL xattr which would unconditionally call cifs_get_acl and cifs_set_acl (even when mounted smb2). I made those protocol independent last week (new protocol version operations "get_acl" and "set_acl" but did not add an smb2_get_acl and smb2_set_acl yet so those now simply return EOPNOTSUPP which at least is better than sending cifs requests on smb2 mount) The previous patches did not fix the one remaining case though ie mounting with "cifsacl" when getting mode from acl would unconditionally end up calling "cifs_get_acl_from_fid" even for smb2 - so made that protocol independent but to make that protocol independent had to make sure that the callers were passing the protocol independent handle structure (cifs_fid) instead of cifs specific _u16 network file handle (ie cifs_fid instead of cifs_fid->fid) Now mount with smb2 and cifsacl mount options will return EOPNOTSUP (instead of timing out) and a future patch will add smb2 operations (e.g. get_smb2_acl) to enable this. Signed-off-by: Steve French <smfrench@gmail.com>
1 parent 4a5c80d commit 42eacf9

7 files changed

Lines changed: 34 additions & 14 deletions

File tree

‎fs/cifs/cifsacl.c‎

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -865,8 +865,8 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
865865
return rc;
866866
}
867867

868-
static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
869-
__u16 fid, u32 *pacllen)
868+
struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
869+
const struct cifs_fid *cifsfid, u32 *pacllen)
870870
{
871871
struct cifs_ntsd *pntsd = NULL;
872872
unsigned int xid;
@@ -877,7 +877,8 @@ static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
877877
return ERR_CAST(tlink);
878878

879879
xid = get_xid();
880-
rc = CIFSSMBGetCIFSACL(xid, tlink_tcon(tlink), fid, &pntsd, pacllen);
880+
rc = CIFSSMBGetCIFSACL(xid, tlink_tcon(tlink), cifsfid->netfid, &pntsd,
881+
pacllen);
881882
free_xid(xid);
882883

883884
cifs_put_tlink(tlink);
@@ -946,7 +947,7 @@ struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb,
946947
if (!open_file)
947948
return get_cifs_acl_by_path(cifs_sb, path, pacllen);
948949

949-
pntsd = get_cifs_acl_by_fid(cifs_sb, open_file->fid.netfid, pacllen);
950+
pntsd = get_cifs_acl_by_fid(cifs_sb, &open_file->fid, pacllen);
950951
cifsFileInfo_put(open_file);
951952
return pntsd;
952953
}
@@ -1006,19 +1007,31 @@ int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
10061007
/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */
10071008
int
10081009
cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
1009-
struct inode *inode, const char *path, const __u16 *pfid)
1010+
struct inode *inode, const char *path,
1011+
const struct cifs_fid *pfid)
10101012
{
10111013
struct cifs_ntsd *pntsd = NULL;
10121014
u32 acllen = 0;
10131015
int rc = 0;
1016+
struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
1017+
struct cifs_tcon *tcon;
10141018

10151019
cifs_dbg(NOISY, "converting ACL to mode for %s\n", path);
10161020

1017-
if (pfid)
1018-
pntsd = get_cifs_acl_by_fid(cifs_sb, *pfid, &acllen);
1019-
else
1020-
pntsd = get_cifs_acl(cifs_sb, inode, path, &acllen);
1021+
if (IS_ERR(tlink))
1022+
return PTR_ERR(tlink);
1023+
tcon = tlink_tcon(tlink);
10211024

1025+
if (pfid && (tcon->ses->server->ops->get_acl_by_fid))
1026+
pntsd = tcon->ses->server->ops->get_acl_by_fid(cifs_sb, pfid,
1027+
&acllen);
1028+
else if (tcon->ses->server->ops->get_acl)
1029+
pntsd = tcon->ses->server->ops->get_acl(cifs_sb, inode, path,
1030+
&acllen);
1031+
else {
1032+
cifs_put_tlink(tlink);
1033+
return -EOPNOTSUPP;
1034+
}
10221035
/* if we can retrieve the ACL, now parse Access Control Entries, ACEs */
10231036
if (IS_ERR(pntsd)) {
10241037
rc = PTR_ERR(pntsd);
@@ -1030,6 +1043,8 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
10301043
cifs_dbg(VFS, "parse sec desc failed rc = %d\n", rc);
10311044
}
10321045

1046+
cifs_put_tlink(tlink);
1047+
10331048
return rc;
10341049
}
10351050

‎fs/cifs/cifsglob.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ struct smb_version_operations {
398398
const struct nls_table *, int);
399399
struct cifs_ntsd * (*get_acl)(struct cifs_sb_info *, struct inode *,
400400
const char *, u32 *);
401+
struct cifs_ntsd * (*get_acl_by_fid)(struct cifs_sb_info *,
402+
const struct cifs_fid *, u32 *);
401403
int (*set_acl)(struct cifs_ntsd *, __u32, struct inode *, const char *,
402404
int);
403405
};

‎fs/cifs/cifsproto.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ extern struct inode *cifs_iget(struct super_block *sb,
151151

152152
extern int cifs_get_inode_info(struct inode **inode, const char *full_path,
153153
FILE_ALL_INFO *data, struct super_block *sb,
154-
int xid, const __u16 *fid);
154+
int xid, const struct cifs_fid *fid);
155155
extern int cifs_get_inode_info_unix(struct inode **pinode,
156156
const unsigned char *search_path,
157157
struct super_block *sb, unsigned int xid);
@@ -162,11 +162,13 @@ extern int cifs_rename_pending_delete(const char *full_path,
162162
const unsigned int xid);
163163
extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb,
164164
struct cifs_fattr *fattr, struct inode *inode,
165-
const char *path, const __u16 *pfid);
165+
const char *path, const struct cifs_fid *pfid);
166166
extern int id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64,
167167
kuid_t, kgid_t);
168168
extern struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *, struct inode *,
169169
const char *, u32 *);
170+
extern struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *,
171+
const struct cifs_fid *, u32 *);
170172
extern int set_cifs_acl(struct cifs_ntsd *, __u32, struct inode *,
171173
const char *, int);
172174

‎fs/cifs/dir.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
378378
xid);
379379
else {
380380
rc = cifs_get_inode_info(&newinode, full_path, buf, inode->i_sb,
381-
xid, &fid->netfid);
381+
xid, fid);
382382
if (newinode) {
383383
if (server->ops->set_lease_key)
384384
server->ops->set_lease_key(newinode, fid);

‎fs/cifs/file.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb,
244244
xid);
245245
else
246246
rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb,
247-
xid, &fid->netfid);
247+
xid, fid);
248248

249249
out:
250250
kfree(buf);

‎fs/cifs/inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ cifs_get_file_info(struct file *filp)
677677
int
678678
cifs_get_inode_info(struct inode **inode, const char *full_path,
679679
FILE_ALL_INFO *data, struct super_block *sb, int xid,
680-
const __u16 *fid)
680+
const struct cifs_fid *fid)
681681
{
682682
bool validinum = false;
683683
__u16 srchflgs;

‎fs/cifs/smb1ops.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,7 @@ struct smb_version_operations smb1_operations = {
10731073
#endif /* CIFS_XATTR */
10741074
#ifdef CONFIG_CIFS_ACL
10751075
.get_acl = get_cifs_acl,
1076+
.get_acl_by_fid = get_cifs_acl_by_fid,
10761077
.set_acl = set_cifs_acl,
10771078
#endif /* CIFS_ACL */
10781079
};

0 commit comments

Comments
 (0)