From: Dan Carpenter <dan.carpenter@xxxxxxxxxx> commit aab98e2dbd648510f8f51b83fbf4721206ccae45 upstream. 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: stable@xxxxxxxxxxxxxxx Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Signed-off-by: Namjae Jeon <linkinjeon@xxxxxxxxxx> Signed-off-by: Steve French <stfrench@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/smb/server/transport_ipc.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/fs/smb/server/transport_ipc.c +++ b/fs/smb/server/transport_ipc.c @@ -567,6 +567,9 @@ ksmbd_ipc_spnego_authen_request(const ch 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) @@ -746,6 +749,9 @@ struct ksmbd_rpc_command *ksmbd_rpc_writ 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; @@ -794,6 +800,9 @@ struct ksmbd_rpc_command *ksmbd_rpc_ioct 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; Patches currently in stable-queue which might be from dan.carpenter@xxxxxxxxxx are queue-6.1/rdma-cxgb4-prevent-potential-integer-overflow-on-32b.patch queue-6.1/dmaengine-ti-edma-fix-of-node-reference-leaks-in-edm.patch queue-6.1/ksmbd-fix-integer-overflows-on-32-bit-systems.patch queue-6.1/binfmt_flat-fix-integer-overflow-bug-on-32-bit-systems.patch queue-6.1/media-imx-jpeg-fix-potential-error-pointer-dereference-in-detach_pm.patch queue-6.1/tipc-re-order-conditions-in-tipc_crypto_key_rcv.patch