Skip to contentSkip to conversation

ksmbd: remove extra byte from ipc_msg_alloc() size calculations

PATCH Superseded Rosen Penev 2 participants 3 messages Jul 24

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ksmbd: remove extra byte from ipc_msg_alloc() size calculations

Three ipc_msg_alloc() calls in transport_ipc.c allocate sizeof(struct) + payload_len + 1, but the extra byte is unnecessary. The payload data is binary and copied with memcpy() to the exact size; no null terminator is needed.

This was present in the original commit that introduced the file, where the structs already used [0] zero-length arrays, so the +1 was never correct.

Fixes 0626e6641f6b ("cifsd: add server handler for central processing and tranport layers")
Assisted-by Opencode:Big-Pickle
---
 fs/smb/server/transport_ipc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/smb/server/transport_ipc.c +3 -3
index 0c581b9624d3..41611c013d81 100644
@@ -658,7 +658,7 @@ ksmbd_ipc_spnego_authen_request(const char *spnego_blob, int blob_len)
 		return NULL;
 
 	msg = ipc_msg_alloc(sizeof(struct ksmbd_spnego_authen_request) +
-			blob_len + 1);
+			blob_len);
 	if (!msg)
 		return NULL;
 
@@ -839,7 +839,7 @@ struct ksmbd_rpc_command *ksmbd_rpc_write(struct ksmbd_session *sess, int handle
 	if (payload_sz > KSMBD_IPC_MAX_PAYLOAD)
 		return NULL;
 
-	msg = ipc_msg_alloc(sizeof(struct ksmbd_rpc_command) + payload_sz + 1);
+	msg = ipc_msg_alloc(sizeof(struct ksmbd_rpc_command) + payload_sz);
 	if (!msg)
 		return NULL;
 
@@ -898,7 +898,7 @@ struct ksmbd_rpc_command *ksmbd_rpc_ioctl(struct ksmbd_session *sess, int handle
 	if (payload_sz > KSMBD_IPC_MAX_PAYLOAD)
 		return NULL;
 
-	msg = ipc_msg_alloc(sizeof(struct ksmbd_rpc_command) + payload_sz + 1);
+	msg = ipc_msg_alloc(sizeof(struct ksmbd_rpc_command) + payload_sz);
 	if (!msg)
 		return NULL;
 
Signature · 1 line
2.55.0
reviewer
#1 lore raw

No Fixes tag is needed. While the extra byte allocation is indeed unnecessary, strictly speaking this isn't a bug.

Quoted 1 line · Rosen Penev
Fixes 0626e6641f6b ("cifsd: add server handler for central processing and tranport layers")
Signature · 3 lines
ChenXiaoSong <[email protected]>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en
reviewer Reviewed-by
#2 lore raw
Quoted 5 lines · ChenXiaoSong

No Fixes tag is needed. While the extra byte allocation is indeed unnecessary, strictly speaking this isn't a bug.

Quoted 1 line · Rosen Penev
Fixes 0626e6641f6b ("cifsd: add server handler for central processing and tranport layers")
Signature · 3 lines
ChenXiaoSong <[email protected]>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en