All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/connector/hdmi: Fix out of bounds memory read
@ 2026-07-23 22:06 John Harrison
  2026-07-29 21:32 ` John Harrison
  2026-08-10  9:43 ` Maxime Ripard
  0 siblings, 2 replies; 3+ messages in thread
From: John Harrison @ 2026-07-23 22:06 UTC (permalink / raw)
  To: dri-devel
  Cc: kernel-dev, Ville Syrjälä, Dmitry Baryshkov,
	Maxime Ripard, Maarten Lankhorst, Thomas Zimmermann, David Airlie,
	Simona Vetter, Dmitry Baryshkov, Daniel Stone, Nicolas Frattaroli,
	Jani Nikula, José Expósito, Laurent Pinchart, stable

A helper function was copying a given audio infoframe into the
connector's copy but using the size of the destination (a generic
target, sized to accept many different data blocks) not the source (a
very specific type of data block). Thus, it was copying 60 bytes of
data from a 28 byte allocation.

Fix that by using the source size instead, together with a build bug
on the source size actually being smaller than the destination.

I hit this running KUnit tests under KASAN (while debugging something
else entirely). In the real world, it seems unlikely to cause an
actual problem. It is a read not a write so it can't corrupt any
memory. However, it could potentially fall off the end of a page and
cause an accvio bug.

Fixes: f378b77227bc ("drm/connector: hdmi: Add Infoframes generation")
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@gmail.com>
Cc: Simona Vetter <simona@ffwll.ch>
Cc: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Cc: Daniel Stone <daniel@fooishbar.org>
Cc: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: "José Expósito" <jose.exposito89@gmail.com>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v6.11+
Signed-off-by: John Harrison <John.Harrison@Igalia.com>
---
 drivers/gpu/drm/display/drm_hdmi_state_helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
index ce17eeefc2da..d6669e36ca1b 100644
--- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
+++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
@@ -1142,7 +1142,8 @@ drm_atomic_helper_connector_hdmi_update_audio_infoframe(struct drm_connector *co
 
 	mutex_lock(&connector->hdmi.infoframes.lock);
 
-	memcpy(&infoframe->data, frame, sizeof(infoframe->data));
+	BUILD_BUG_ON(sizeof(*frame) > sizeof(infoframe->data));
+	memcpy(&infoframe->data, frame, sizeof(*frame));
 	infoframe->set = true;
 
 	ret = write_infoframe(connector, &funcs->audio, "Audio", infoframe);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/connector/hdmi: Fix out of bounds memory read
  2026-07-23 22:06 [PATCH] drm/connector/hdmi: Fix out of bounds memory read John Harrison
@ 2026-07-29 21:32 ` John Harrison
  2026-08-10  9:43 ` Maxime Ripard
  1 sibling, 0 replies; 3+ messages in thread
From: John Harrison @ 2026-07-29 21:32 UTC (permalink / raw)
  To: dri-devel, Maxime Ripard, Dmitry Baryshkov,
	Ville Syrjälä
  Cc: kernel-dev, Dmitry Baryshkov, Maarten Lankhorst,
	Thomas Zimmermann, David Airlie, Simona Vetter, Daniel Stone,
	Nicolas Frattaroli, Jani Nikula, José Expósito,
	Laurent Pinchart, stable

Ping for review?

It might be an unlikely problem but a potential accvio with a trivial 
fix seems like something we should get merged.

Thanks,
John.

On 7/23/26 15:06, John Harrison wrote:
> A helper function was copying a given audio infoframe into the
> connector's copy but using the size of the destination (a generic
> target, sized to accept many different data blocks) not the source (a
> very specific type of data block). Thus, it was copying 60 bytes of
> data from a 28 byte allocation.
>
> Fix that by using the source size instead, together with a build bug
> on the source size actually being smaller than the destination.
>
> I hit this running KUnit tests under KASAN (while debugging something
> else entirely). In the real world, it seems unlikely to cause an
> actual problem. It is a read not a write so it can't corrupt any
> memory. However, it could potentially fall off the end of a page and
> cause an accvio bug.
>
> Fixes: f378b77227bc ("drm/connector: hdmi: Add Infoframes generation")
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: David Airlie <airlied@gmail.com>
> Cc: Simona Vetter <simona@ffwll.ch>
> Cc: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> Cc: Daniel Stone <daniel@fooishbar.org>
> Cc: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Cc: "José Expósito" <jose.exposito89@gmail.com>
> Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> Cc: dri-devel@lists.freedesktop.org
> Cc: <stable@vger.kernel.org> # v6.11+
> Signed-off-by: John Harrison <John.Harrison@Igalia.com>
> ---
>   drivers/gpu/drm/display/drm_hdmi_state_helper.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> index ce17eeefc2da..d6669e36ca1b 100644
> --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
> @@ -1142,7 +1142,8 @@ drm_atomic_helper_connector_hdmi_update_audio_infoframe(struct drm_connector *co
>   
>   	mutex_lock(&connector->hdmi.infoframes.lock);
>   
> -	memcpy(&infoframe->data, frame, sizeof(infoframe->data));
> +	BUILD_BUG_ON(sizeof(*frame) > sizeof(infoframe->data));
> +	memcpy(&infoframe->data, frame, sizeof(*frame));
>   	infoframe->set = true;
>   
>   	ret = write_infoframe(connector, &funcs->audio, "Audio", infoframe);


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/connector/hdmi: Fix out of bounds memory read
  2026-07-23 22:06 [PATCH] drm/connector/hdmi: Fix out of bounds memory read John Harrison
  2026-07-29 21:32 ` John Harrison
@ 2026-08-10  9:43 ` Maxime Ripard
  1 sibling, 0 replies; 3+ messages in thread
From: Maxime Ripard @ 2026-08-10  9:43 UTC (permalink / raw)
  To: dri-devel, John Harrison
  Cc: Maxime Ripard, kernel-dev, Ville Syrjälä,
	Maarten Lankhorst, Thomas Zimmermann, David Airlie, Simona Vetter,
	Dmitry Baryshkov, Daniel Stone, Nicolas Frattaroli, Jani Nikula,
	José Expósito, Laurent Pinchart, stable,
	Dmitry Baryshkov

On Thu, 23 Jul 2026 15:06:52 -0700, John Harrison wrote:
> A helper function was copying a given audio infoframe into the
> connector's copy but using the size of the destination (a generic
> target, sized to accept many different data blocks) not the source (a
> very specific type of data block). Thus, it was copying 60 bytes of
> data from a 28 byte allocation.
> 
> Fix that by using the source size instead, together with a build bug
> on the source size actually being smaller than the destination.
> 
> [...]

Applied to misc/kernel.git (drm-misc-fixes).

Thanks!
Maxime

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-10  9:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-23 22:06 [PATCH] drm/connector/hdmi: Fix out of bounds memory read John Harrison
2026-07-29 21:32 ` John Harrison
2026-08-10  9:43 ` Maxime Ripard

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.