ksmbd: remove extra byte from ipc_msg_alloc() size calculations
Subsystems (2)
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
Signed-off-by Rosen Penev <[email protected]>
--- fs/smb/server/transport_ipc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/smb/server/transport_ipc.c +3 -3
@@ -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 handleif (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 handleif (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
ChenXiaoSong
reviewerNo 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
Reviewed-by ChenXiaoSong <[email protected]>
Quoted 5 lines · ChenXiaoSong
No
Fixestag 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