Patch "ksmbd: handle smb2 query dir request for OutputBufferLength that is too small" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ksmbd: handle smb2 query dir request for OutputBufferLength that is too small

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ksmbd-handle-smb2-query-dir-request-for-outputbuffer.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 8f9ac24503b16997fb4074618756ca6e150ac530
Author: Namjae Jeon <linkinjeon@xxxxxxxxxx>
Date:   Mon May 16 16:22:09 2022 +0900

    ksmbd: handle smb2 query dir request for OutputBufferLength that is too small
    
    [ Upstream commit 65ca7a3ffff811d6c0d4342d467c381257d566d4 ]
    
    We found the issue that ksmbd return STATUS_NO_MORE_FILES response
    even though there are still dentries that needs to be read while
    file read/write test using framtest utils.
    windows client send smb2 query dir request included
    OutputBufferLength(128) that is too small to contain even one entry.
    This patch make ksmbd immediately returns OutputBufferLength of response
    as zero to client.
    
    Signed-off-by: Namjae Jeon <linkinjeon@xxxxxxxxxx>
    Reviewed-by: Hyunchul Lee <hyc.lee@xxxxxxxxx>
    Signed-off-by: Steve French <stfrench@xxxxxxxxxxxxx>
    Stable-dep-of: 88541cb414b7 ("ksmbd: fix incorrect handling of iterate_dir")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
index bec9a84572c0..ef0aef78eba6 100644
--- a/fs/ksmbd/smb2pdu.c
+++ b/fs/ksmbd/smb2pdu.c
@@ -3962,6 +3962,12 @@ int smb2_query_dir(struct ksmbd_work *work)
 	set_ctx_actor(&dir_fp->readdir_data.ctx, __query_dir);
 
 	rc = iterate_dir(dir_fp->filp, &dir_fp->readdir_data.ctx);
+	/*
+	 * req->OutputBufferLength is too small to contain even one entry.
+	 * In this case, it immediately returns OutputBufferLength 0 to client.
+	 */
+	if (!d_info.out_buf_len && !d_info.num_entry)
+		goto no_buf_len;
 	if (rc == 0)
 		restart_ctx(&dir_fp->readdir_data.ctx);
 	if (rc == -ENOSPC)
@@ -3988,10 +3994,12 @@ int smb2_query_dir(struct ksmbd_work *work)
 		rsp->Buffer[0] = 0;
 		inc_rfc1001_len(rsp_org, 9);
 	} else {
+no_buf_len:
 		((struct file_directory_info *)
 		((char *)rsp->Buffer + d_info.last_entry_offset))
 		->NextEntryOffset = 0;
-		d_info.data_count -= d_info.last_entry_off_align;
+		if (d_info.data_count >= d_info.last_entry_off_align)
+			d_info.data_count -= d_info.last_entry_off_align;
 
 		rsp->StructureSize = cpu_to_le16(9);
 		rsp->OutputBufferOffset = cpu_to_le16(72);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux