Skip to content

Commit

Permalink
ksmbd: fix integer overflows on 32 bit systems
Browse files Browse the repository at this point in the history
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: 0626e6641f6b ("cifsd: add server handler for central processing and tranport layers")
Cc: [email protected]
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
Dan Carpenter authored and namjaejeon committed Jan 15, 2025
1 parent 88e6e7f commit ee998af
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions transport_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,9 @@ ksmbd_ipc_spnego_authen_request(const char *spnego_blob, int blob_len)
struct ksmbd_spnego_authen_request *req;
struct ksmbd_spnego_authen_response *resp;

if (blob_len > KSMBD_IPC_MAX_PAYLOAD)
return NULL;

msg = ipc_msg_alloc(sizeof(struct ksmbd_spnego_authen_request) +
blob_len + 1);
if (!msg)
Expand Down Expand Up @@ -807,6 +810,9 @@ struct ksmbd_rpc_command *ksmbd_rpc_write(struct ksmbd_session *sess, int handle
struct ksmbd_rpc_command *req;
struct ksmbd_rpc_command *resp;

if (payload_sz > KSMBD_IPC_MAX_PAYLOAD)
return NULL;

msg = ipc_msg_alloc(sizeof(struct ksmbd_rpc_command) + payload_sz + 1);
if (!msg)
return NULL;
Expand Down Expand Up @@ -855,6 +861,9 @@ struct ksmbd_rpc_command *ksmbd_rpc_ioctl(struct ksmbd_session *sess, int handle
struct ksmbd_rpc_command *req;
struct ksmbd_rpc_command *resp;

if (payload_sz > KSMBD_IPC_MAX_PAYLOAD)
return NULL;

msg = ipc_msg_alloc(sizeof(struct ksmbd_rpc_command) + payload_sz + 1);
if (!msg)
return NULL;
Expand All @@ -880,6 +889,9 @@ struct ksmbd_rpc_command *ksmbd_rpc_rap(struct ksmbd_session *sess, void *payloa
struct ksmbd_rpc_command *req;
struct ksmbd_rpc_command *resp;

if (payload_sz > KSMBD_IPC_MAX_PAYLOAD)
return NULL;

msg = ipc_msg_alloc(sizeof(struct ksmbd_rpc_command) + payload_sz + 1);
if (!msg)
return NULL;
Expand Down

0 comments on commit ee998af

Please sign in to comment.