Message ID | 20220812025614.5673-1-linkinjeon@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ksmbd: don't remove dos attribute xattr on O_TRUNC open | expand |
2022년 8월 12일 (금) 오전 11:56, 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. > > Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> > --- > fs/ksmbd/smb2pdu.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c > index b5c36657ecfd..0c2e57397dd2 100644 > --- a/fs/ksmbd/smb2pdu.c > +++ b/fs/ksmbd/smb2pdu.c > @@ -2330,9 +2330,7 @@ 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) && > + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) && > strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX, STREAM_PREFIX_LEN)) > continue; > We don't need to exclude security.*, trusted.*, system.* from deletion? > -- > 2.25.1 >
2022-08-14 11:19 GMT+09:00, Hyunchul Lee <hyc.lee@gmail.com>: > 2022년 8월 12일 (금) 오전 11:56, 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. >> >> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> >> --- >> fs/ksmbd/smb2pdu.c | 4 +--- >> 1 file changed, 1 insertion(+), 3 deletions(-) >> >> diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c >> index b5c36657ecfd..0c2e57397dd2 100644 >> --- a/fs/ksmbd/smb2pdu.c >> +++ b/fs/ksmbd/smb2pdu.c >> @@ -2330,9 +2330,7 @@ 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) && >> + if (!strncmp(name, XATTR_USER_PREFIX, >> XATTR_USER_PREFIX_LEN) && >> strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX, >> STREAM_PREFIX_LEN)) >> continue; >> > > We don't need to exclude security.*, trusted.*, system.* from deletion? Right, will fix it on v2. Thanks. > >> -- >> 2.25.1 >> > > > -- > Thanks, > Hyunchul >
diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c index b5c36657ecfd..0c2e57397dd2 100644 --- a/fs/ksmbd/smb2pdu.c +++ b/fs/ksmbd/smb2pdu.c @@ -2330,9 +2330,7 @@ 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) && + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) && strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX, STREAM_PREFIX_LEN)) continue;
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. Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> --- fs/ksmbd/smb2pdu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)