ksmbd: don't remove dos attribute xattr on O_TRUNC open
Subsystems (3)
Namjae Jeon
maintainerPATCH v3 1/1 ksmbd: don't remove dos attribute xattr on O_TRUNC open
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.
---
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(-)
fs/ksmbd/smb2pdu.c +9 -9
@@ -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);
Signature · 1 line
2.25.1
2022년 8월 14일 (일) 오후 10:53, Namjae Jeon <[email protected]>님이 작성:
Quoted 10 lines
When smb client open file in ksmbd share with
O_TRUNC, dos attribute xattr is removed as well as data in file. This cause theFSCTL_SET_SPARSErequest from the client fails because ksmbd can't update the dos attribute after settingATTR_SPARSE_FILE. And this patch fix xfstests generic/469 test also.Fixes e2f34481b24d ("cifsd: add server-side procedures for SMB3")Signed-off-by Namjae Jeon <[email protected]>
Quoted 42 lines
---
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(-)fs/ksmbd/smb2pdu.c +9
-10@@ -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
Signature · 2 lines
Thanks, Hyunchul