Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 2bfc421

Browse files
namjaejeonSteve French
authored andcommitted
ksmbd: fix missing use of get_write in in smb2_set_ea()
Fix an issue where get_write is not used in smb2_set_ea(). Fixes: 6fc0a26 ("ksmbd: fix potential circular locking issue in smb2_set_ea()") Cc: stable@vger.kernel.org Reported-by: Wang Zhaolong <wangzhaolong1@huawei.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 1cdeca6 commit 2bfc421

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

fs/smb/server/smb2pdu.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,7 +2367,8 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
23672367
if (rc > 0) {
23682368
rc = ksmbd_vfs_remove_xattr(idmap,
23692369
path,
2370-
attr_name);
2370+
attr_name,
2371+
get_write);
23712372

23722373
if (rc < 0) {
23732374
ksmbd_debug(SMB,
@@ -2382,7 +2383,7 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
23822383
} else {
23832384
rc = ksmbd_vfs_setxattr(idmap, path, attr_name, value,
23842385
le16_to_cpu(eabuf->EaValueLength),
2385-
0, true);
2386+
0, get_write);
23862387
if (rc < 0) {
23872388
ksmbd_debug(SMB,
23882389
"ksmbd_vfs_setxattr is failed(%d)\n",
@@ -2474,7 +2475,7 @@ static int smb2_remove_smb_xattrs(const struct path *path)
24742475
!strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX,
24752476
STREAM_PREFIX_LEN)) {
24762477
err = ksmbd_vfs_remove_xattr(idmap, path,
2477-
name);
2478+
name, true);
24782479
if (err)
24792480
ksmbd_debug(SMB, "remove xattr failed : %s\n",
24802481
name);

fs/smb/server/vfs.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,16 +1058,21 @@ int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length,
10581058
}
10591059

10601060
int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap,
1061-
const struct path *path, char *attr_name)
1061+
const struct path *path, char *attr_name,
1062+
bool get_write)
10621063
{
10631064
int err;
10641065

1065-
err = mnt_want_write(path->mnt);
1066-
if (err)
1067-
return err;
1066+
if (get_write == true) {
1067+
err = mnt_want_write(path->mnt);
1068+
if (err)
1069+
return err;
1070+
}
10681071

10691072
err = vfs_removexattr(idmap, path->dentry, attr_name);
1070-
mnt_drop_write(path->mnt);
1073+
1074+
if (get_write == true)
1075+
mnt_drop_write(path->mnt);
10711076

10721077
return err;
10731078
}
@@ -1380,7 +1385,7 @@ int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, const struct path *path)
13801385
ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name));
13811386

13821387
if (!strncmp(name, XATTR_NAME_SD, XATTR_NAME_SD_LEN)) {
1383-
err = ksmbd_vfs_remove_xattr(idmap, path, name);
1388+
err = ksmbd_vfs_remove_xattr(idmap, path, name, true);
13841389
if (err)
13851390
ksmbd_debug(SMB, "remove xattr failed : %s\n", name);
13861391
}

fs/smb/server/vfs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ int ksmbd_vfs_setxattr(struct mnt_idmap *idmap,
114114
int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name,
115115
size_t *xattr_stream_name_size, int s_type);
116116
int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap,
117-
const struct path *path, char *attr_name);
117+
const struct path *path, char *attr_name,
118+
bool get_write);
118119
int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
119120
unsigned int flags, struct path *parent_path,
120121
struct path *path, bool caseless);

fs/smb/server/vfs_cache.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ static void __ksmbd_inode_close(struct ksmbd_file *fp)
254254
ci->m_flags &= ~S_DEL_ON_CLS_STREAM;
255255
err = ksmbd_vfs_remove_xattr(file_mnt_idmap(filp),
256256
&filp->f_path,
257-
fp->stream.name);
257+
fp->stream.name,
258+
true);
258259
if (err)
259260
pr_err("remove xattr failed : %s\n",
260261
fp->stream.name);

0 commit comments

Comments
 (0)