Skip to content

Commit 40b268d

Browse files
namjaejeonSteve French
authored and
Steve French
committed
ksmbd: add mnt_want_write to ksmbd vfs functions
ksmbd is doing write access using vfs helpers. There are the cases that mnt_want_write() is not called in vfs helper. This patch add missing mnt_want_write() to ksmbd vfs functions. Cc: [email protected] Cc: Amir Goldstein <[email protected]> Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 2b9b8f3 commit 40b268d

File tree

5 files changed

+117
-55
lines changed

5 files changed

+117
-55
lines changed

fs/smb/server/smb2pdu.c

+11-15
Original file line numberDiff line numberDiff line change
@@ -2249,7 +2249,7 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
22492249
/* delete the EA only when it exits */
22502250
if (rc > 0) {
22512251
rc = ksmbd_vfs_remove_xattr(idmap,
2252-
path->dentry,
2252+
path,
22532253
attr_name);
22542254

22552255
if (rc < 0) {
@@ -2263,8 +2263,7 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
22632263
/* if the EA doesn't exist, just do nothing. */
22642264
rc = 0;
22652265
} else {
2266-
rc = ksmbd_vfs_setxattr(idmap,
2267-
path->dentry, attr_name, value,
2266+
rc = ksmbd_vfs_setxattr(idmap, path, attr_name, value,
22682267
le16_to_cpu(eabuf->EaValueLength), 0);
22692268
if (rc < 0) {
22702269
ksmbd_debug(SMB,
@@ -2321,8 +2320,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
23212320
return -EBADF;
23222321
}
23232322

2324-
rc = ksmbd_vfs_setxattr(idmap, path->dentry,
2325-
xattr_stream_name, NULL, 0, 0);
2323+
rc = ksmbd_vfs_setxattr(idmap, path, xattr_stream_name, NULL, 0, 0);
23262324
if (rc < 0)
23272325
pr_err("Failed to store XATTR stream name :%d\n", rc);
23282326
return 0;
@@ -2350,7 +2348,7 @@ static int smb2_remove_smb_xattrs(const struct path *path)
23502348
if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) &&
23512349
!strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX,
23522350
STREAM_PREFIX_LEN)) {
2353-
err = ksmbd_vfs_remove_xattr(idmap, path->dentry,
2351+
err = ksmbd_vfs_remove_xattr(idmap, path,
23542352
name);
23552353
if (err)
23562354
ksmbd_debug(SMB, "remove xattr failed : %s\n",
@@ -2397,8 +2395,7 @@ static void smb2_new_xattrs(struct ksmbd_tree_connect *tcon, const struct path *
23972395
da.flags = XATTR_DOSINFO_ATTRIB | XATTR_DOSINFO_CREATE_TIME |
23982396
XATTR_DOSINFO_ITIME;
23992397

2400-
rc = ksmbd_vfs_set_dos_attrib_xattr(mnt_idmap(path->mnt),
2401-
path->dentry, &da);
2398+
rc = ksmbd_vfs_set_dos_attrib_xattr(mnt_idmap(path->mnt), path, &da);
24022399
if (rc)
24032400
ksmbd_debug(SMB, "failed to store file attribute into xattr\n");
24042401
}
@@ -2972,7 +2969,7 @@ int smb2_open(struct ksmbd_work *work)
29722969
struct inode *inode = d_inode(path.dentry);
29732970

29742971
posix_acl_rc = ksmbd_vfs_inherit_posix_acl(idmap,
2975-
path.dentry,
2972+
&path,
29762973
d_inode(path.dentry->d_parent));
29772974
if (posix_acl_rc)
29782975
ksmbd_debug(SMB, "inherit posix acl failed : %d\n", posix_acl_rc);
@@ -2988,7 +2985,7 @@ int smb2_open(struct ksmbd_work *work)
29882985
if (rc) {
29892986
if (posix_acl_rc)
29902987
ksmbd_vfs_set_init_posix_acl(idmap,
2991-
path.dentry);
2988+
&path);
29922989

29932990
if (test_share_config_flag(work->tcon->share_conf,
29942991
KSMBD_SHARE_FLAG_ACL_XATTR)) {
@@ -3028,7 +3025,7 @@ int smb2_open(struct ksmbd_work *work)
30283025

30293026
rc = ksmbd_vfs_set_sd_xattr(conn,
30303027
idmap,
3031-
path.dentry,
3028+
&path,
30323029
pntsd,
30333030
pntsd_size);
30343031
kfree(pntsd);
@@ -5464,7 +5461,7 @@ static int smb2_rename(struct ksmbd_work *work,
54645461
goto out;
54655462

54665463
rc = ksmbd_vfs_setxattr(file_mnt_idmap(fp->filp),
5467-
fp->filp->f_path.dentry,
5464+
&fp->filp->f_path,
54685465
xattr_stream_name,
54695466
NULL, 0, 0);
54705467
if (rc < 0) {
@@ -5629,8 +5626,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
56295626
da.flags = XATTR_DOSINFO_ATTRIB | XATTR_DOSINFO_CREATE_TIME |
56305627
XATTR_DOSINFO_ITIME;
56315628

5632-
rc = ksmbd_vfs_set_dos_attrib_xattr(idmap,
5633-
filp->f_path.dentry, &da);
5629+
rc = ksmbd_vfs_set_dos_attrib_xattr(idmap, &filp->f_path, &da);
56345630
if (rc)
56355631
ksmbd_debug(SMB,
56365632
"failed to restore file attribute in EA\n");
@@ -7485,7 +7481,7 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,
74857481

74867482
da.attr = le32_to_cpu(fp->f_ci->m_fattr);
74877483
ret = ksmbd_vfs_set_dos_attrib_xattr(idmap,
7488-
fp->filp->f_path.dentry, &da);
7484+
&fp->filp->f_path, &da);
74897485
if (ret)
74907486
fp->f_ci->m_fattr = old_fattr;
74917487
}

fs/smb/server/smbacl.c

+4-6
Original file line numberDiff line numberDiff line change
@@ -1162,8 +1162,7 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,
11621162
pntsd_size += sizeof(struct smb_acl) + nt_size;
11631163
}
11641164

1165-
ksmbd_vfs_set_sd_xattr(conn, idmap,
1166-
path->dentry, pntsd, pntsd_size);
1165+
ksmbd_vfs_set_sd_xattr(conn, idmap, path, pntsd, pntsd_size);
11671166
kfree(pntsd);
11681167
}
11691168

@@ -1383,7 +1382,7 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
13831382
newattrs.ia_valid |= ATTR_MODE;
13841383
newattrs.ia_mode = (inode->i_mode & ~0777) | (fattr.cf_mode & 0777);
13851384

1386-
ksmbd_vfs_remove_acl_xattrs(idmap, path->dentry);
1385+
ksmbd_vfs_remove_acl_xattrs(idmap, path);
13871386
/* Update posix acls */
13881387
if (IS_ENABLED(CONFIG_FS_POSIX_ACL) && fattr.cf_dacls) {
13891388
rc = set_posix_acl(idmap, path->dentry,
@@ -1414,9 +1413,8 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
14141413

14151414
if (test_share_config_flag(tcon->share_conf, KSMBD_SHARE_FLAG_ACL_XATTR)) {
14161415
/* Update WinACL in xattr */
1417-
ksmbd_vfs_remove_sd_xattrs(idmap, path->dentry);
1418-
ksmbd_vfs_set_sd_xattr(conn, idmap,
1419-
path->dentry, pntsd, ntsd_len);
1416+
ksmbd_vfs_remove_sd_xattrs(idmap, path);
1417+
ksmbd_vfs_set_sd_xattr(conn, idmap, path, pntsd, ntsd_len);
14201418
}
14211419

14221420
out:

0 commit comments

Comments
 (0)