Skip to content

Commit 867ffd9

Browse files
llllIIIllllgregkh
authored andcommitted
ksmbd: transport_ipc: validate payload size before reading handle
commit 6f40e50 upstream. handle_response() dereferences the payload as a 4-byte handle without verifying that the declared payload size is at least 4 bytes. A malformed or truncated message from ksmbd.mountd can lead to a 4-byte read past the declared payload size. Validate the size before dereferencing. This is a minimal fix to guard the initial handle read. Fixes: 0626e66 ("cifsd: add server handler for central processing and tranport layers") Cc: stable@vger.kernel.org Reported-by: Qianchang Zhao <pioooooooooip@gmail.com> Signed-off-by: Qianchang Zhao <pioooooooooip@gmail.com> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1caa8b9 commit 867ffd9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

fs/smb/server/transport_ipc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,16 @@ static void ipc_msg_handle_free(int handle)
263263

264264
static int handle_response(int type, void *payload, size_t sz)
265265
{
266-
unsigned int handle = *(unsigned int *)payload;
266+
unsigned int handle;
267267
struct ipc_msg_table_entry *entry;
268268
int ret = 0;
269269

270+
/* Prevent 4-byte read beyond declared payload size */
271+
if (sz < sizeof(unsigned int))
272+
return -EINVAL;
273+
274+
handle = *(unsigned int *)payload;
275+
270276
ipc_update_last_active();
271277
down_read(&ipc_msg_table_lock);
272278
hash_for_each_possible(ipc_msg_table, entry, ipc_table_hlist, handle) {

0 commit comments

Comments
 (0)