Skip to content

Commit aab98e2

Browse files
Dan CarpenterSteve French
authored andcommitted
ksmbd: fix integer overflows on 32 bit systems
On 32bit systems the addition operations in ipc_msg_alloc() can potentially overflow leading to memory corruption. Add bounds checking using KSMBD_IPC_MAX_PAYLOAD to avoid overflow. Fixes: 0626e66 ("cifsd: add server handler for central processing and tranport layers") Cc: stable@vger.kernel.org Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent b2d9937 commit aab98e2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

fs/smb/server/transport_ipc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,9 @@ ksmbd_ipc_spnego_authen_request(const char *spnego_blob, int blob_len)
627627
struct ksmbd_spnego_authen_request *req;
628628
struct ksmbd_spnego_authen_response *resp;
629629

630+
if (blob_len > KSMBD_IPC_MAX_PAYLOAD)
631+
return NULL;
632+
630633
msg = ipc_msg_alloc(sizeof(struct ksmbd_spnego_authen_request) +
631634
blob_len + 1);
632635
if (!msg)
@@ -806,6 +809,9 @@ struct ksmbd_rpc_command *ksmbd_rpc_write(struct ksmbd_session *sess, int handle
806809
struct ksmbd_rpc_command *req;
807810
struct ksmbd_rpc_command *resp;
808811

812+
if (payload_sz > KSMBD_IPC_MAX_PAYLOAD)
813+
return NULL;
814+
809815
msg = ipc_msg_alloc(sizeof(struct ksmbd_rpc_command) + payload_sz + 1);
810816
if (!msg)
811817
return NULL;
@@ -854,6 +860,9 @@ struct ksmbd_rpc_command *ksmbd_rpc_ioctl(struct ksmbd_session *sess, int handle
854860
struct ksmbd_rpc_command *req;
855861
struct ksmbd_rpc_command *resp;
856862

863+
if (payload_sz > KSMBD_IPC_MAX_PAYLOAD)
864+
return NULL;
865+
857866
msg = ipc_msg_alloc(sizeof(struct ksmbd_rpc_command) + payload_sz + 1);
858867
if (!msg)
859868
return NULL;

0 commit comments

Comments
 (0)