Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: lyude@redhat.com
To: Ashutosh Desai <ashutoshdesai993@gmail.com>,
	 dri-devel@lists.freedesktop.org
Cc: stable@vger.kernel.org, Dave Airlie <airlied@gmail.com>,
	Daniel Vetter <daniel@ffwll.ch>
Subject: Re: [PATCH] drm/dp/mst: fix buffer overflows in sideband chunk accumulation
Date: Thu, 07 May 2026 14:07:19 -0400	[thread overview]
Message-ID: <02ebf0e092a810cbb61eaab13a0cd6f46881c23f.camel@redhat.com> (raw)
In-Reply-To: <20260410041901.2438960-1-ashutoshdesai993@gmail.com>

Reviewed-by: Lyude Paul <lyude@redhat.com>

Will push to drm-misc in a moment

On Fri, 2026-04-10 at 04:19 +0000, Ashutosh Desai wrote:
> drm_dp_sideband_append_payload() has three related bugs when
> processing
> device-provided sideband reply data:
> 
> 1. Zero-length curchunk_len underflow: msg_len is a 6-bit field taken
>    directly from the DP sideband header. If a device sends msg_len=0,
>    curchunk_len is set to zero. The condition (curchunk_idx >=
> curchunk_len)
>    is immediately true, and curchunk_len-1 wraps to 255 (u8
> underflow).
>    drm_dp_msg_data_crc4() reads 255 bytes from chunk[48], then
> memcpy()
>    writes 255 bytes into msg[], both far out of bounds.
> 
> 2. chunk[48] overflow: curchunk_len can reach 63 (6-bit field).
> chunk[] is
>    only 48 bytes. Multi-iteration payload assembly appends 16-byte
> blocks
>    until curchunk_idx reaches curchunk_len, writing up to 15 bytes
> past
>    the end of chunk[] into msg[].
> 
> 3. msg[256] overflow: each chunk contributes (curchunk_len-1) bytes
> to
>    msg[]. No check ensures curlen + (curchunk_len-1) stays within
> msg[256],
>    so the memcpy can spill into adjacent struct fields.
> 
> All three are reachable from any DP MST device that can forge
> sideband
> reply messages on a physical connection.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Ashutosh Desai <ashutoshdesai993@gmail.com>
> ---
>  drivers/gpu/drm/display/drm_dp_mst_topology.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c
> b/drivers/gpu/drm/display/drm_dp_mst_topology.c
> index f2a7dbc5e..5261a4a54 100644
> --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c
> @@ -789,6 +789,12 @@ static bool
> drm_dp_sideband_append_payload(struct drm_dp_sideband_msg_rx *msg,
>  {
>  	u8 crc4;
>  
> +	/* curchunk_len must be >= 1 (min 1 CRC byte) and fit in
> chunk[] */
> +	if (!msg->curchunk_len ||
> +	    msg->curchunk_len > ARRAY_SIZE(msg->chunk) ||
> +	    msg->curchunk_idx + replybuflen > ARRAY_SIZE(msg-
> >chunk))
> +		return false;
> +
>  	memcpy(&msg->chunk[msg->curchunk_idx], replybuf,
> replybuflen);
>  	msg->curchunk_idx += replybuflen;
>  
> @@ -799,6 +805,9 @@ static bool drm_dp_sideband_append_payload(struct
> drm_dp_sideband_msg_rx *msg,
>  			print_hex_dump(KERN_DEBUG, "wrong crc",
>  				       DUMP_PREFIX_NONE, 16, 1,
>  				       msg->chunk,  msg-
> >curchunk_len, false);
> +		/* Guard against accumulated msg[] overflow */
> +		if (msg->curlen + msg->curchunk_len - 1 >
> ARRAY_SIZE(msg->msg))
> +			return false;
>  		/* copy chunk into bigger msg */
>  		memcpy(&msg->msg[msg->curlen], msg->chunk, msg-
> >curchunk_len - 1);
>  		msg->curlen += msg->curchunk_len - 1;


      parent reply	other threads:[~2026-05-07 18:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-10  4:19 [PATCH] drm/dp/mst: fix buffer overflows in sideband chunk accumulation Ashutosh Desai
2026-05-07  0:34 ` Ashutosh Desai
2026-05-07 18:07 ` 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=02ebf0e092a810cbb61eaab13a0cd6f46881c23f.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=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