From: lyude@redhat.com
To: Ashutosh Desai <ashutoshdesai993@gmail.com>,
dri-devel@lists.freedesktop.org
Cc: stable@vger.kernel.org, airlied@gmail.com, daniel@ffwll.ch,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de, simona@ffwll.ch,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] drm/dp/mst: fix OOB reads in remote DPCD/I2C sideband reply parsers
Date: Mon, 18 May 2026 13:51:11 -0400 [thread overview]
Message-ID: <b8ca839c8561ad301f24921ea4c37b2cb129c4d8.camel@redhat.com> (raw)
In-Reply-To: <20260510201733.2882224-1-ashutoshdesai993@gmail.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Will push to drm-misc in just a moment
On Sun, 2026-05-10 at 20:17 +0000, Ashutosh Desai wrote:
> drm_dp_sideband_parse_remote_dpcd_read() reads num_bytes from the raw
> message and then unconditionally does:
>
> memcpy(bytes, &raw->msg[idx], num_bytes);
>
> without checking that idx + num_bytes <= raw->curlen. raw->msg[] is
> 256 bytes; if a malicious or misbehaving MST hub sets num_bytes
> larger
> than the remaining payload, the memcpy reads past the received data
> into whatever follows in raw->msg[].
>
> drm_dp_sideband_parse_remote_i2c_read_ack() has the same flaw (noted
> with a /* TODO check */ comment since the code was introduced).
>
> Fix both functions by using a single combined check
> (idx + num_bytes > curlen) before each memcpy. Since num_bytes is u8,
> it is always >= 0, so this strictly subsumes the simpler idx > curlen
> form and no separate step is needed.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Ashutosh Desai <ashutoshdesai993@gmail.com>
> ---
> Changes in v2:
> - Drop separate idx > curlen check; idx + num_bytes > curlen with u8
> num_bytes (always >= 0) strictly subsumes it (Lyude Paul)
>
> drivers/gpu/drm/display/drm_dp_mst_topology.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c
> b/drivers/gpu/drm/display/drm_dp_mst_topology.c
> index 170113520a43..9416a48804c8 100644
> --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c
> @@ -871,7 +871,7 @@ static bool
> drm_dp_sideband_parse_remote_dpcd_read(struct drm_dp_sideband_msg_rx
> goto fail_len;
> repmsg->u.remote_dpcd_read_ack.num_bytes = raw->msg[idx];
> idx++;
> - if (idx > raw->curlen)
> + if (idx + repmsg->u.remote_dpcd_read_ack.num_bytes > raw-
> >curlen)
> goto fail_len;
>
> memcpy(repmsg->u.remote_dpcd_read_ack.bytes, &raw->msg[idx],
> repmsg->u.remote_dpcd_read_ack.num_bytes);
> @@ -907,7 +907,9 @@ static bool
> drm_dp_sideband_parse_remote_i2c_read_ack(struct drm_dp_sideband_msg
> goto fail_len;
> repmsg->u.remote_i2c_read_ack.num_bytes = raw->msg[idx];
> idx++;
> - /* TODO check */
> + if (idx + repmsg->u.remote_i2c_read_ack.num_bytes > raw-
> >curlen)
> + goto fail_len;
> +
> memcpy(repmsg->u.remote_i2c_read_ack.bytes, &raw->msg[idx],
> repmsg->u.remote_i2c_read_ack.num_bytes);
> return true;
> fail_len:
prev parent reply other threads:[~2026-05-18 17:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-10 20:17 Ashutosh Desai
2026-05-18 17:51 ` lyude [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=b8ca839c8561ad301f24921ea4c37b2cb129c4d8.camel@redhat.com \
--to=lyude@redhat.com \
--cc=airlied@gmail.com \
--cc=ashutoshdesai993@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
--cc=tzimmermann@suse.de \
/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®