* [PATCH v3] ksmbd: don't remove dos attribute xattr on O_TRUNC open
@ 2022-08-14 13:52 Namjae Jeon
2022-08-15 11:16 ` Hyunchul Lee
0 siblings, 1 reply; 2+ messages in thread
From: Namjae Jeon @ 2022-08-14 13:52 UTC (permalink / raw)
To: linux-cifs; +Cc: smfrench, hyc.lee, senozhatsky, Namjae Jeon, stable
When smb client open file in ksmbd share with O_TRUNC, dos attribute
xattr is removed as well as data in file. This cause the FSCTL_SET_SPARSE
request from the client fails because ksmbd can't update the dos attribute
after setting ATTR_SPARSE_FILE. And this patch fix xfstests generic/469
test also.
Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Cc: stable@vger.kernel.org
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
v2:
- don't remove other xattr class also.
- add fixes and stable tags.
v3:
- Change to more simpler check.
fs/ksmbd/smb2pdu.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
index a136d5e4943b..19412ac701a6 100644
--- a/fs/ksmbd/smb2pdu.c
+++ b/fs/ksmbd/smb2pdu.c
@@ -2330,15 +2330,15 @@ static int smb2_remove_smb_xattrs(struct path *path)
name += strlen(name) + 1) {
ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name));
- if (strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) &&
- strncmp(&name[XATTR_USER_PREFIX_LEN], DOS_ATTRIBUTE_PREFIX,
- DOS_ATTRIBUTE_PREFIX_LEN) &&
- strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX, STREAM_PREFIX_LEN))
- continue;
-
- err = ksmbd_vfs_remove_xattr(user_ns, path->dentry, name);
- if (err)
- ksmbd_debug(SMB, "remove xattr failed : %s\n", name);
+ if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) &&
+ !strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX,
+ STREAM_PREFIX_LEN)) {
+ err = ksmbd_vfs_remove_xattr(user_ns, path->dentry,
+ name);
+ if (err)
+ ksmbd_debug(SMB, "remove xattr failed : %s\n",
+ name);
+ }
}
out:
kvfree(xattr_list);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] ksmbd: don't remove dos attribute xattr on O_TRUNC open
2022-08-14 13:52 [PATCH v3] ksmbd: don't remove dos attribute xattr on O_TRUNC open Namjae Jeon
@ 2022-08-15 11:16 ` Hyunchul Lee
0 siblings, 0 replies; 2+ messages in thread
From: Hyunchul Lee @ 2022-08-15 11:16 UTC (permalink / raw)
To: Namjae Jeon; +Cc: linux-cifs, smfrench, senozhatsky, stable
2022년 8월 14일 (일) 오후 10:53, Namjae Jeon <linkinjeon@kernel.org>님이 작성:
>
> When smb client open file in ksmbd share with O_TRUNC, dos attribute
> xattr is removed as well as data in file. This cause the FSCTL_SET_SPARSE
> request from the client fails because ksmbd can't update the dos attribute
> after setting ATTR_SPARSE_FILE. And this patch fix xfstests generic/469
> test also.
>
> Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
> Cc: stable@vger.kernel.org
> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
> ---
> v2:
> - don't remove other xattr class also.
> - add fixes and stable tags.
> v3:
> - Change to more simpler check.
>
> fs/ksmbd/smb2pdu.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
> index a136d5e4943b..19412ac701a6 100644
> --- a/fs/ksmbd/smb2pdu.c
> +++ b/fs/ksmbd/smb2pdu.c
> @@ -2330,15 +2330,15 @@ static int smb2_remove_smb_xattrs(struct path *path)
> name += strlen(name) + 1) {
> ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name));
>
> - if (strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) &&
> - strncmp(&name[XATTR_USER_PREFIX_LEN], DOS_ATTRIBUTE_PREFIX,
> - DOS_ATTRIBUTE_PREFIX_LEN) &&
> - strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX, STREAM_PREFIX_LEN))
> - continue;
> -
> - err = ksmbd_vfs_remove_xattr(user_ns, path->dentry, name);
> - if (err)
> - ksmbd_debug(SMB, "remove xattr failed : %s\n", name);
> + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) &&
> + !strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX,
> + STREAM_PREFIX_LEN)) {
> + err = ksmbd_vfs_remove_xattr(user_ns, path->dentry,
> + name);
> + if (err)
> + ksmbd_debug(SMB, "remove xattr failed : %s\n",
> + name);
> + }
> }
> out:
> kvfree(xattr_list);
> --
> 2.25.1
>
--
Thanks,
Hyunchul
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-15 11:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-14 13:52 [PATCH v3] ksmbd: don't remove dos attribute xattr on O_TRUNC open Namjae Jeon
2022-08-15 11:16 ` Hyunchul Lee
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox