All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alex Huang" <Alex.Huang2@amd.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/4] drm/amd/display: Use HDMI FreeSync range from common EDID parser
Date: Tue, 21 Jul 2026 17:03:48 +0000	[thread overview]
Message-ID: <20260721170348.B6BB91F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260721164430.2121326-3-Alex.Huang2@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing payload length checks in AMD VSDB version 2 and 3 parsing leads to out-of-bounds memory reads when processing malformed EDIDs.
--

--- Patch [2]: [PATCH 2/4] drm/amd/display: Use HDMI FreeSync range from common EDID parser ---
commit 1c50a992def070041d1c59487f692155608cc345
Author: Alex Huang <Alex.Huang2@amd.com>
Subject: drm/amd/display: Use HDMI FreeSync range from common EDID parser

This commit modifies the AMD GPU display driver to use the common DRM EDID
parser for detecting HDMI FreeSync capabilities, rather than relying on the
AMD VSDB parser in the DMUB firmware.

> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 9c564cd5edeea..fd9bb205c8f08 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

[ ... ]

> @@ -13932,8 +13770,8 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
>  		}
>  
>  	} else if (drm_edid && sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A) {
> -		i = parse_hdmi_amd_vsdb(amdgpu_dm_connector, edid, &vsdb_info);
> -		if (i >= 0) {
> +		i = get_amd_vsdb(amdgpu_dm_connector, &vsdb_info);
> +		if (i) {

[Severity: High]
Does relying on the common DRM EDID parser here expose us to out-of-bounds
memory reads when processing malformed EDIDs?

Looking at the common parser in drivers/gpu/drm/drm_edid.c,
drm_parse_amd_vsdb() fails to validate the payload length before delegating
to version-specific parsers:

drivers/gpu/drm/drm_edid.c:drm_parse_amd_vsdb() {
    ...
	info->amd_vsdb.version = common->version;

	drm_parse_amd_vsdb_v1(info, data);

	if (common->version >= 2)
		drm_parse_amd_vsdb_v2(info, data);

	if (common->version >= 3)
		drm_parse_amd_vsdb_v3(info, data, cea_db_payload_len(db));
}

The v2 parser unconditionally accesses struct fields up to offset 12 without
checking if the payload length is sufficient:

drivers/gpu/drm/drm_edid.c:drm_parse_amd_vsdb_v2() {
    ...
	info->amd_vsdb.luminance_range1.max_luminance = p->lum1_max;
	info->amd_vsdb.luminance_range1.min_luminance = p->lum1_min;
	info->amd_vsdb.luminance_range2.max_luminance = p->lum2_max;
	info->amd_vsdb.luminance_range2.min_luminance = p->lum2_min;
    ...
}

Similarly, the v3 parser unconditionally accesses fields up to offset 14:

drivers/gpu/drm/drm_edid.c:drm_parse_amd_vsdb_v3() {
    ...
	/* vfreq is provded in a different set of fields for v3. */
	max_frame_rate = p->max_vfreq_ext_low |
			 (p->max_vfreq_ext_high & 0x3) << 8;
    ...
}

If a monitor provides an AMD VSDB block with version 2 or 3 but a payload
length smaller than required, could this lead to an out-of-bounds read of
up to 7 bytes in the slab?

>  			amdgpu_dm_connector->vsdb_info = vsdb_info;
>  			sink->edid_caps.freesync_vcp_code = vsdb_info.freesync_mccs_vcp_code;
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260721164430.2121326-1-Alex.Huang2@amd.com?part=2

  reply	other threads:[~2026-07-21 17:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21 16:44 [PATCH 0/4] drm/edid: Parse AMD VSDB FreeSync range in common code Alex Huang
2026-07-21 16:44 ` [PATCH 1/4] drm/edid: Parse AMD VSDB for FreeSync refresh range Alex Huang
2026-07-21 16:54   ` sashiko-bot
2026-07-21 17:00   ` Mario Limonciello
2026-07-21 16:44 ` [PATCH 2/4] drm/amd/display: Use HDMI FreeSync range from common EDID parser Alex Huang
2026-07-21 17:03   ` sashiko-bot [this message]
2026-07-21 16:44 ` [PATCH 3/4] drm/amd/display: Clean up FreeSync capability detection Alex Huang
2026-07-21 16:55   ` sashiko-bot
2026-07-21 16:44 ` [PATCH 4/4] drm/amd/display: Remove unused DMCU/DMUB EDID CEA parser Alex Huang
2026-07-21 16:59   ` sashiko-bot

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=20260721170348.B6BB91F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Alex.Huang2@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.