Skip to content

Commit 1ec7215

Browse files
namjaejeonSteve French
authored andcommitted
ksmbd: contain default data stream even if xattr is empty
If xattr is not supported like exfat or fat, ksmbd server doesn't contain default data stream in FILE_STREAM_INFORMATION response. It will cause ppt or doc file update issue if local filesystem is such as ones. This patch move goto statement to contain it. Fixes: 9f63233 ("ksmbd: add default data stream name in FILE_STREAM_INFORMATION") Cc: stable@vger.kernel.org # v5.15 Acked-by: Hyunchul Lee <hyc.lee@gmail.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 8e537d1 commit 1ec7215

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

fs/ksmbd/smb2pdu.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4459,6 +4459,12 @@ static void get_file_stream_info(struct ksmbd_work *work,
44594459
&stat);
44604460
file_info = (struct smb2_file_stream_info *)rsp->Buffer;
44614461

4462+
buf_free_len =
4463+
smb2_calc_max_out_buf_len(work, 8,
4464+
le32_to_cpu(req->OutputBufferLength));
4465+
if (buf_free_len < 0)
4466+
goto out;
4467+
44624468
xattr_list_len = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
44634469
if (xattr_list_len < 0) {
44644470
goto out;
@@ -4467,12 +4473,6 @@ static void get_file_stream_info(struct ksmbd_work *work,
44674473
goto out;
44684474
}
44694475

4470-
buf_free_len =
4471-
smb2_calc_max_out_buf_len(work, 8,
4472-
le32_to_cpu(req->OutputBufferLength));
4473-
if (buf_free_len < 0)
4474-
goto out;
4475-
44764476
while (idx < xattr_list_len) {
44774477
stream_name = xattr_list + idx;
44784478
streamlen = strlen(stream_name);
@@ -4516,6 +4516,7 @@ static void get_file_stream_info(struct ksmbd_work *work,
45164516
file_info->NextEntryOffset = cpu_to_le32(next);
45174517
}
45184518

4519+
out:
45194520
if (!S_ISDIR(stat.mode) &&
45204521
buf_free_len >= sizeof(struct smb2_file_stream_info) + 7 * 2) {
45214522
file_info = (struct smb2_file_stream_info *)
@@ -4524,14 +4525,13 @@ static void get_file_stream_info(struct ksmbd_work *work,
45244525
"::$DATA", 7, conn->local_nls, 0);
45254526
streamlen *= 2;
45264527
file_info->StreamNameLength = cpu_to_le32(streamlen);
4527-
file_info->StreamSize = 0;
4528-
file_info->StreamAllocationSize = 0;
4528+
file_info->StreamSize = cpu_to_le64(stat.size);
4529+
file_info->StreamAllocationSize = cpu_to_le64(stat.blocks << 9);
45294530
nbytes += sizeof(struct smb2_file_stream_info) + streamlen;
45304531
}
45314532

45324533
/* last entry offset should be 0 */
45334534
file_info->NextEntryOffset = 0;
4534-
out:
45354535
kvfree(xattr_list);
45364536

45374537
rsp->OutputBufferLength = cpu_to_le32(nbytes);

0 commit comments

Comments
 (0)