From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Lianjie Wang <lian@is.s.u-tokyo.ac.jp>
Cc: Bjorn Andersson <andersson@kernel.org>,
Ohad Ben-Cohen <ohad@wizery.com>,
linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org,
Takahiro Shinagawa <shina@is.s.u-tokyo.ac.jp>,
stable@vger.kernel.org
Subject: Re: [PATCH v2] rpmsg: virtio: Reject a message shorter than its header
Date: Mon, 9 Nov 2026 09:05:32 -0600 [thread overview]
Message-ID: <avHhPI5btZcuhKsZ@p14s> (raw)
In-Reply-To: <20261106232322.1093165-1-lian@is.s.u-tokyo.ac.jp>
On Sat, Nov 07, 2026 at 08:23:22AM +0900, Lianjie Wang wrote:
> rpmsg_recv_single() checks the msg_len field of a message header against
> the used length with an unsigned subtraction, so every msg_len passes
> the check with a used length shorter than the header. The rx callback of
> the destination endpoint can receive a message of up to 65535 bytes,
> longer than the default receive buffer of 512 bytes, so rpmsg_char can
> copy the whole message into an skb and read past the buffer:
>
> BUG: KASAN: slab-out-of-bounds in rpmsg_ept_cb+0x4d/0xb0
> Read of size 65535 at addr ffff888002484010 by task rpmsg_echo/140
> Call Trace:
> rpmsg_ept_cb+0x4d/0xb0
> rpmsg_recv_done+0x29f/0x840
> vring_interrupt+0x32a/0x540
> vp_interrupt+0x146/0x180
>
> Compare the sum of the header size and msg_len with the used length, so
> no subtraction wraps.
>
> This patch is assisted by Claude Opus 5.5.
>
> Fixes: 9648224e564a ("rpmsg: validate incoming message length before propagating")
> Cc: stable@vger.kernel.org
> Signed-off-by: Lianjie Wang <lian@is.s.u-tokyo.ac.jp>
> ---
> v2:
> - Leave the check after the dynamic_hex_dump statement.
> v1: https://lore.kernel.org/all/20261102221504.175116-1-lian@is.s.u-tokyo.ac.jp/
>
> drivers/rpmsg/virtio_rpmsg_bus.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
> index 23ff6c8b7a20b..3d58bb19e9297 100644
> --- a/drivers/rpmsg/virtio_rpmsg_bus.c
> +++ b/drivers/rpmsg/virtio_rpmsg_bus.c
> @@ -676,7 +676,7 @@ static int rpmsg_recv_single(struct virtproc_info *vrp, struct device *dev,
> * the reported payload length.
> */
> if (len > vrp->rx_buf_size ||
> - msg_len > (len - sizeof(struct rpmsg_hdr))) {
> + sizeof(struct rpmsg_hdr) + msg_len > len) {
Applied.
Thanks,
Mathieu
> dev_warn(dev, "inbound msg too big: (%d, %d)\n", len, msg_len);
> return -EINVAL;
> }
>
> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
> --
> 2.56.0
>
prev parent reply other threads:[~2026-11-09 15:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 23:23 Lianjie Wang
2026-11-09 15:05 ` Mathieu Poirier [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=avHhPI5btZcuhKsZ@p14s \
--to=mathieu.poirier@linaro.org \
--cc=andersson@kernel.org \
--cc=lian@is.s.u-tokyo.ac.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=ohad@wizery.com \
--cc=shina@is.s.u-tokyo.ac.jp \
--cc=stable@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®