Re: [PATCH] slimbus: messaging: fix out-of-bounds write in slim_msg_response()
From: Srinivas Kandagatla
Date: Tue Nov 24 2026 - 16:43:34 EST
On 11/20/26 8:50 AM, zhangjiao2 wrote:
> From: zhang jiao <zhangjiao2@xxxxxxxxxxxxxxxxxxxx>
>
> slim_msg_response() copies the reply payload into the client receive
> buffer using the length reported by the controller, without checking it
> against the msg->num_bytes for which the buffer was sized.
>
> The reply length originates from the message received on the bus (the
> RL field of the message header) and is therefore controlled by the
> remote SLIM device. A buggy or malicious remote, e.g. the firmware
> driving the Qualcomm NGD controller, can send a reply longer than the
Do you have a hardware that does show this behavior? or is this
hypothetical?
> requested number of bytes and slim_msg_response() then writes past the
> end of the client buffer. Client buffers are typically small, for
> example the single stack byte used by slim_readb(), so this can corrupt
> adjacent stack or heap memory.
>
> Clamp the reply length to msg->num_bytes and report the protocol error
> so that the transaction still completes normally (freeing the TID and
> dropping the runtime PM vote) without overflowing the receive buffer.
>
You said its a fix but I dont see any fixes tag or Stable.
--srini
> Signed-off-by: zhang jiao <zhangjiao2@xxxxxxxxxxxxxxxxxxxx>
> ---
> drivers/slimbus/messaging.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/slimbus/messaging.c b/drivers/slimbus/messaging.c
> index ee127ef42046..b20864b59606 100644
> --- a/drivers/slimbus/messaging.c
> +++ b/drivers/slimbus/messaging.c
> @@ -41,6 +41,13 @@ void slim_msg_response(struct slim_controller *ctrl, u8 *reply, u8 tid, u8 len)
> return;
> }
>
> + if (len > msg->num_bytes) {
> + dev_err(ctrl->dev,
> + "Got response with invalid length:%d for TID:%d, expected:%d\n",
> + len, tid, msg->num_bytes);
> + len = msg->num_bytes;
> + }
> +
> slim_free_txn_tid(ctrl, txn);
> memcpy(msg->rbuf, reply, len);
> if (txn->comp)