Skip to content

Commit a02e432

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: [email protected] Reported-by: Qianchang Zhao <[email protected]> Signed-off-by: Qianchang Zhao <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b83ce5c commit a02e432

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
@@ -249,10 +249,16 @@ static void ipc_msg_handle_free(int handle)
249249

250250
static int handle_response(int type, void *payload, size_t sz)
251251
{
252-
unsigned int handle = *(unsigned int *)payload;
252+
unsigned int handle;
253253
struct ipc_msg_table_entry *entry;
254254
int ret = 0;
255255

256+
/* Prevent 4-byte read beyond declared payload size */
257+
if (sz < sizeof(unsigned int))
258+
return -EINVAL;
259+
260+
handle = *(unsigned int *)payload;
261+
256262
ipc_update_last_active();
257263
down_read(&ipc_msg_table_lock);
258264
hash_for_each_possible(ipc_msg_table, entry, ipc_table_hlist, handle) {

0 commit comments

Comments
 (0)