From: Srinivas Kandagatla <srini@kernel.org>
To: zhangjiao2 <zhangjiao2@cmss.chinamobile.com>, gregkh@linuxfoundation.org
Cc: srini@kernel.org, zhouzongmin@kylinos.cn,
linux-kernel@vger.kernel.org, trivial@kernel.org
Subject: Re: [PATCH] slimbus: messaging: fix out-of-bounds write in slim_msg_response()
Date: Tue, 24 Nov 2026 21:43:28 +0000 [thread overview]
Message-ID: <d774e2db-d584-49a3-9413-ff594ee33fa7@kernel.org> (raw)
In-Reply-To: <20261120085011.2080-1-zhangjiao2@cmss.chinamobile.com>
On 11/20/26 8:50 AM, zhangjiao2 wrote:
> From: zhang jiao <zhangjiao2@cmss.chinamobile.com>
>
> 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@cmss.chinamobile.com>
> ---
> 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)
prev parent reply other threads:[~2026-11-24 21:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 8:50 [PATCH] slimbus: messaging: fix out-of-bounds write in slim_msg_response() zhangjiao2
2026-11-24 21:43 ` Srinivas Kandagatla [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d774e2db-d584-49a3-9413-ff594ee33fa7@kernel.org \
--to=srini@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=trivial@kernel.org \
--cc=zhangjiao2@cmss.chinamobile.com \
--cc=zhouzongmin@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.