ksmbd: fix type confusion via race condition when using ipc_msg_send_request
authorNamjae Jeon <linkinjeon@kernel.org>
Fri, 21 Feb 2025 05:16:23 +0000 (14:16 +0900)
committerSteve French <stfrench@microsoft.com>
Mon, 3 Mar 2025 04:50:53 +0000 (22:50 -0600)
req->handle is allocated using ksmbd_acquire_id(&ipc_ida), based on
ida_alloc. req->handle from ksmbd_ipc_login_request and
FSCTL_PIPE_TRANSCEIVE ioctl can be same and it could lead to type confusion
between messages, resulting in access to unexpected parts of memory after
an incorrect delivery. ksmbd check type of ipc response but missing add
continue to check next ipc reponse.

Cc: stable@vger.kernel.org
Reported-by: Norbert Szetei <norbert@doyensec.com>
Tested-by: Norbert Szetei <norbert@doyensec.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/transport_ipc.c

index 0460ebea6ff02859e80288c6b9a6a5b24bf445fc..3f185ae60dc514fa0bdb00f3b074d0e50da8e637 100644 (file)
@@ -281,6 +281,7 @@ static int handle_response(int type, void *payload, size_t sz)
                if (entry->type + 1 != type) {
                        pr_err("Waiting for IPC type %d, got %d. Ignore.\n",
                               entry->type + 1, type);
+                       continue;
                }
 
                entry->response = kvzalloc(sz, KSMBD_DEFAULT_GFP);