[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211005081022.1.Ib059f9c23c2611cb5a9d760e7d0a700c1295928d@changeid>
Date: Tue, 5 Oct 2021 08:10:28 -0700
From: Douglas Anderson <dianders@...omium.org>
To: dri-devel@...ts.freedesktop.org
Cc: Rodrigo.Siqueira@....com, ville.syrjala@...ux.intel.com,
Harry.Wentland@....com, khsieh@...eaurora.org, Jerry.Zuo@....com,
alexander.deucher@....com,
Douglas Anderson <dianders@...omium.org>,
Daniel Vetter <daniel@...ll.ch>,
David Airlie <airlied@...ux.ie>,
Harry Wentland <harry.wentland@....com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
linux-kernel@...r.kernel.org
Subject: [PATCH] drm/edid: In connector_bad_edid() cap num_of_ext by num_blocks read
In commit e11f5bd8228f ("drm: Add support for DP 1.4 Compliance edid
corruption test") the function connector_bad_edid() started assuming
that the memory for the EDID passed to it was big enough to hold
`edid[0x7e] + 1` blocks of data (1 extra for the base block). It
completely ignored the fact that the function was passed `num_blocks`
which indicated how much memory had been allocated for the EDID.
Let's fix this by adding a bounds check.
This is important for handling the case where there's an error in the
first block of the EDID. In that case we will call
connector_bad_edid() without having re-allocated memory based on
`edid[0x7e]`.
Fixes: e11f5bd8228f ("drm: Add support for DP 1.4 Compliance edid corruption test")
Reported-by: Ville Syrjälä <ville.syrjala@...ux.intel.com>
Signed-off-by: Douglas Anderson <dianders@...omium.org>
---
This problem report came up in the context of a patch I sent out [1]
and this is my attempt at a fix. The problem predates my patch,
though. I don't personally know anything about DP compliance testing
and what should be happening here, nor do I apparently have any
hardware that actually reports a bad EDID. Thus this is just compile
tested. I'm hoping that someone here can test this and make sure it
seems OK to them.
drivers/gpu/drm/drm_edid.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 9b19eee0e1b4..ccfa08631c57 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -1843,8 +1843,9 @@ static void connector_bad_edid(struct drm_connector *connector,
u8 num_of_ext = edid[0x7e];
/* Calculate real checksum for the last edid extension block data */
- connector->real_edid_checksum =
- drm_edid_block_checksum(edid + num_of_ext * EDID_LENGTH);
+ if (num_of_ext <= num_blocks - 1)
+ connector->real_edid_checksum =
+ drm_edid_block_checksum(edid + num_of_ext * EDID_LENGTH);
if (connector->bad_edid_counter++ && !drm_debug_enabled(DRM_UT_KMS))
return;
--
2.33.0.800.g4c38ced690-goog
Powered by blists - more mailing lists