ksmbd: transport_ipc: validate payload size before reading handle
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): 2025102125-petted-gristle-43a0@gregkh
PATCH 1/1 ksmbd: transport_ipc: validate payload size before reading handle
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.
--- fs/smb/server/transport_ipc.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/smb/server/transport_ipc.c +4 -0
@@ -263,6 +263,10 @@ static void ipc_msg_handle_free(int handle)static int handle_response (int type,void *payload,size_t sz) { +/* Prevent 4-byte read beyond declared payload size */ +if (sz <sizeof (unsigned int )) +return -EINVAL ; +unsigned int handle = *(unsigned int *)payload;struct ipc_msg_table_entry *entry;int ret =0 ;
Signature · 1 line
2.34.1
Quoted 6 lines · Qianchang Zhao
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.
Quoted 6 lines
This is a minimal fix to guard the initial handle read.
Fixes 0626e6641f6b ("cifsd: add server handler for central processing and tranport layers")Reported-by Qianchang Zhao <[email protected]>Signed-off-by Qianchang Zhao <[email protected]>
I have directly updated your patch. Can you check the attached patch ? Thanks!
From 177af6102527571eaa381323dddd7084c203353e Mon Sep 17 00:00:00 2001
From: Qianchang Zhao <[email protected]>
Date: Wed, 22 Oct 2025 15:27:47 +0900
Subject: [PATCH] ksmbd: transport_ipc: validate payload size before reading
handle
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.
--- fs/smb/server/transport_ipc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/smb/server/transport_ipc.c +7 -1
@@ -263,10 +263,16 @@ static void ipc_msg_handle_free(int handle)static int handle_response (int type,void *payload,size_t sz) { -unsigned int handle = *(unsigned int *)payload; +unsigned int handle;struct ipc_msg_table_entry *entry;int ret =0 ; +/* Prevent 4-byte read beyond declared payload size */ +if (sz <sizeof (unsigned int )) +return -EINVAL ; + + handle = *(unsigned int *)payload; +ipc_update_last_active ();down_read (&ipc_msg_table_lock);hash_for_each_possible (ipc_msg_table, entry, ipc_table_hlist, handle) {
Signature · 1 line
2.25.1
Hi Namjae, Steve,
Thanks for updating the patch. I’ve reviewed the changes and they look good to me.
Minor impact note: this patch prevents a 4-byte out-of-bounds read in ksmbd's handle_response() when the declared Generic Netlink payload size is < 4.
If a remote client can influence ksmbd.mountd to emit a truncated payload, this could be remotely triggerable (info-leak/DoS potential). If you consider this security-impacting, I’m happy to request a CVE via the kernel.org CNA.
Thanks!!
Qianchang Zhao
Quoted 16 lines · Namjae Jeon
Quoted 6 lines · Qianchang Zhao
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.Quoted 6 lines
This is a minimal fix to guard the initial handle read.
Fixes 0626e6641f6b ("cifsd: add server handler for central processing and tranport layers")Reported-by Qianchang Zhao <[email protected]>Signed-off-by Qianchang Zhao <[email protected]>I have directly updated your patch. Can you check the attached patch ? Thanks!
A message that is not in the archive (sent off-list or not yet received): CAFgAp7g52dJDvJyEoV7Ms-YofG6a2=G=N16ARNrBOiCSkLVLTw@mail.gmail.com
Namjae Jeon
maintainerQuoted 2 lines · くさあさ
Hi Namjae, Steve,
Hi,
Quoted 2 lines
Thanks for updating the patch. I’ve reviewed the changes and they look good to me.
Okay.
Quoted 3 lines
Minor impact note: this patch prevents a 4-byte out-of-bounds read in ksmbd’s
handle_response()when the declared Generic Netlink payload size is < 4. If a remote client can influence ksmbd.mountd to emit a truncated payload, this could be remotely triggerable (info-leak/DoS potential).
I don't understand how this is possible. Could you please explain it to me via private email?
Quoted 4 lines
If you consider this security-impacting, I’m happy to request a CVE via the kernel.org CNA.
Thanks!!
Qianchang Zhao