FAILED: patch "[PATCH] drm/i915/hdcp: check streams[] bounds before overflow" failed to apply to 6.6-stable tree
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x bbb15a6b042d02e5508a02b4847e02d2579ee7bc
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026072917-dugout-sufferer-eb18@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From bbb15a6b042d02e5508a02b4847e02d2579ee7bc Mon Sep 17 00:00:00 2001
From: Jani Nikula <[email protected]>
Date: Thu, 25 Jun 2026 20:03:04 +0300
Subject: [PATCH] drm/i915/hdcp: check streams[] bounds before overflow
The data->streams[] overflow check is done after the buffer overflow has already happened. Move the overflow check before the write.
Side note, emitting a warning splat with a backtrace might be overkill here, but prefer not changing the behaviour other than not doing the overrun.
Discovered using AI-assisted static analysis confirmed by Intel Product Security.
drivers/gpu/drm/i915/display/intel_hdcp.c +4 -1
@@ -145,6 +145,9 @@ intel_hdcp_required_content_stream(struct intel_atomic_state *state,if (!new_conn_state || !new_conn_state->crtc)continue ; +if (drm_WARN_ON (display->drm, data->k >=INTEL_NUM_PIPES (display))) +return -EINVAL ; + data->streams[data->k].stream_id =intel_conn_to_vcpi (state, connector); data->k++;
@@ -155,7 +158,7 @@ intel_hdcp_required_content_stream(struct intel_atomic_state *state, }drm_connector_list_iter_end (&conn_iter); -if (drm_WARN_ON (display->drm, data->k >INTEL_NUM_PIPES (display) || data->k ==0 )) +if (drm_WARN_ON (display->drm, !data->k))return -EINVAL ;/*
Sasha Levin
maintainerPATCH 1/4 drm/i915/fbc: Extract intel_fbc_has_fences()
From: Ville Syrjälä <[email protected]>
[ Upstream commit bc34d310b578952d37b5200a7fa7475ab2a2bd5e ]
Pull the "do we have fences?" check into a single helper in the FBC code. Avoids having to call to outside the display code in multiple places for this.
Stable-dep-of: bbb15a6b042d ("drm/i915/hdcp: check streams[] bounds before overflow")
--- drivers/gpu/drm/i915/display/intel_fbc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/intel_fbc.c +7 -2
@@ -223,6 +223,11 @@ static u16 intel_fbc_override_cfb_stride(const struct intel_plane_state *plane_sreturn 0 ; } +static bool intel_fbc_has_fences (struct drm_i915_private *i915) +{ +return intel_gt_support_legacy_fencing (to_gt (i915)); +} +static u32 i8xx_fbc_ctl (struct intel_fbc *fbc) {const struct intel_fbc_state *fbc_state = &fbc->state;
@@ -608,7 +613,7 @@ static void ivb_fbc_activate(struct intel_fbc *fbc)else if (DISPLAY_VER (i915) ==9 )skl_fbc_program_cfb_stride (fbc); -if (intel_gt_support_legacy_fencing (to_gt (i915))) +if (intel_fbc_has_fences (i915))snb_fbc_program_fence (fbc); intel_de_write(i915, ILK_DPFC_CONTROL(fbc->id),
@@ -992,7 +997,7 @@ static void intel_fbc_update_state(struct intel_atomic_state *state, fbc_state->fence_y_offset =intel_plane_fence_y_offset (plane_state);drm_WARN_ON (&i915->drm, plane_state->flags &PLANE_HAS_FENCE && - !intel_gt_support_legacy_fencing (to_gt (i915))); + !intel_fbc_has_fences (i915));if (plane_state->flags &PLANE_HAS_FENCE ) fbc_state->fence_id =i915_vma_fence_id (plane_state->ggtt_vma);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/4 drm/i915/hdcp: migrate away from kdev_to_i915() in bind/unbind
From: Jani Nikula <[email protected]>
[ Upstream commit 3eac4684ecb5ea696bd283bd7f35e4829973f4f8 ]
Use to_intel_display() instead of kdev_to_i915() in the HDCP component API hooks. Avoid further drive-by changes at this point, and just convert the display pointer to i915, and leave the struct intel_display conversion for later.
Stable-dep-of: bbb15a6b042d ("drm/i915/hdcp: check streams[] bounds before overflow")
--- drivers/gpu/drm/i915/display/intel_hdcp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/display/intel_hdcp.c +6 -4
@@ -2108,10 +2108,11 @@ static void intel_hdcp_check_work(struct work_struct *work) DRM_HDCP_CHECK_PERIOD_MS); } -static int i915_hdcp_component_bind (struct device *i915_kdev, +static int i915_hdcp_component_bind (struct device *drv_kdev,struct device *mei_kdev,void *data) { -struct drm_i915_private *i915 =kdev_to_i915 (i915_kdev); +struct intel_display *display =to_intel_display (drv_kdev); +struct drm_i915_private *i915 =to_i915 (display->drm);drm_dbg (&i915->drm,"I915 HDCP comp bind\n" );mutex_lock (&i915->display.hdcp.hdcp_mutex);
@@ -2122,10 +2123,11 @@ static int i915_hdcp_component_bind(struct device *i915_kdev,return 0 ; } -static void i915_hdcp_component_unbind (struct device *i915_kdev, +static void i915_hdcp_component_unbind (struct device *drv_kdev,struct device *mei_kdev,void *data) { -struct drm_i915_private *i915 =kdev_to_i915 (i915_kdev); +struct intel_display *display =to_intel_display (drv_kdev); +struct drm_i915_private *i915 =to_i915 (display->drm);drm_dbg (&i915->drm,"I915 HDCP comp unbind\n" );mutex_lock (&i915->display.hdcp.hdcp_mutex);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/4 drm/i915/hdcp: Skip inactive MST connectors when building stream list
In reply to Sasha LevinFrom: Suraj Kandpal <[email protected]>
[ Upstream commit 0161e2c2016337a2f22ef79dff0aee43c0841bce ]
intel_hdcp_required_content_stream() walks every connector on the digital port to populate hdcp_port_data->streams[]. The only filter is connector_status_disconnected, which reflects physical presence on the MST topology, not whether the connector currently drives a stream. On a multi-sink MST setup where only a subset of sinks are modeset, the loop can pick a sibling MST connector that is connected but has no active CRTC / VC payload. intel_conn_to_vcpi() then logs "MST Payload not present" and returns 0, and the bogus StreamID=0 is written to the repeater in RepeaterAuth_Stream_Manage (DPCD 0x693F0). Authentication completes, but the repeater shortly raises LINK_INTEGRITY_FAILURE (RxStatus 0x69493 bit4) because the StreamID does not match any stream on its input. The HDCP check work then tears the link down, the Content Protection property drops back to DESIRED, and userspace observes a spurious HDCP enable failure. Filter the connector iteration to only those with a CRTC assigned in the new atomic state, so intel_conn_to_vcpi() is called for the connector actually being enabled and reads its real VCPI from the MST topology state.
Stable-dep-of: bbb15a6b042d ("drm/i915/hdcp: check streams[] bounds before overflow")
--- drivers/gpu/drm/i915/display/intel_hdcp.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/display/intel_hdcp.c +11 -7
@@ -30,7 +30,7 @@#define KEY_LOAD_TRIES 5#define HDCP2_LC_RETRY_CNT 3 -static int intel_conn_to_vcpi (struct drm_atomic_state *state, +static int intel_conn_to_vcpi (struct intel_atomic_state *state,struct intel_connector *connector) {struct drm_dp_mst_topology_mgr *mgr;
@@ -43,7 +43,7 @@ static int intel_conn_to_vcpi(struct drm_atomic_state *state,return 0 ; mgr = connector->port->mgr; -drm_modeset_lock (&mgr->base.lock, state->acquire_ctx); +drm_modeset_lock (&mgr->base.lock, state->base.acquire_ctx); mst_state =to_drm_dp_mst_topology_state (mgr->base.state); payload =drm_atomic_get_mst_payload_state (mst_state, connector->port);if (drm_WARN_ON (mgr->dev, !payload))
@@ -2111,8 +2111,7 @@ static void intel_hdcp_check_work(struct work_struct *work)static int i915_hdcp_component_bind (struct device *drv_kdev,struct device *mei_kdev,void *data) { -struct intel_display *display =to_intel_display (drv_kdev); -struct drm_i915_private *i915 =to_i915 (display->drm); +struct drm_i915_private *i915 =kdev_to_i915 (drv_kdev);drm_dbg (&i915->drm,"I915 HDCP comp bind\n" );mutex_lock (&i915->display.hdcp.hdcp_mutex);
@@ -2126,8 +2125,7 @@ static int i915_hdcp_component_bind(struct device *drv_kdev,static void i915_hdcp_component_unbind (struct device *drv_kdev,struct device *mei_kdev,void *data) { -struct intel_display *display =to_intel_display (drv_kdev); -struct drm_i915_private *i915 =to_i915 (display->drm); +struct drm_i915_private *i915 =kdev_to_i915 (drv_kdev);drm_dbg (&i915->drm,"I915 HDCP comp unbind\n" );mutex_lock (&i915->display.hdcp.hdcp_mutex);
@@ -2297,6 +2295,7 @@ intel_hdcp_set_streams(struct intel_digital_port *dig_port, struct intel_atomic_state *state) {struct drm_connector_list_iter conn_iter; +struct drm_connector_state *new_conn_state;struct intel_digital_port *conn_dig_port;struct intel_connector *connector;struct drm_i915_private *i915 =to_i915 (dig_port->base.base.dev);
@@ -2322,8 +2321,13 @@ intel_hdcp_set_streams(struct intel_digital_port *dig_port,if (conn_dig_port != dig_port)continue ; + new_conn_state =drm_atomic_get_new_connector_state (&state->base, + &connector->base); +if (!new_conn_state || !new_conn_state->crtc) +continue ; + data->streams[data->k].stream_id = -intel_conn_to_vcpi (&state->base, connector); +intel_conn_to_vcpi (state, connector); data->k++;/* if there is only one active stream */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 4/4 drm/i915/hdcp: check streams[] bounds before overflow
In reply to Sasha LevinFrom: Jani Nikula <[email protected]>
[ Upstream commit bbb15a6b042d02e5508a02b4847e02d2579ee7bc ]
The data->streams[] overflow check is done after the buffer overflow has already happened. Move the overflow check before the write.
Side note, emitting a warning splat with a backtrace might be overkill here, but prefer not changing the behaviour other than not doing the overrun.
Discovered using AI-assisted static analysis confirmed by Intel Product Security.
--- drivers/gpu/drm/i915/display/intel_hdcp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_hdcp.c +4 -1
@@ -2326,6 +2326,9 @@ intel_hdcp_set_streams(struct intel_digital_port *dig_port,if (!new_conn_state || !new_conn_state->crtc)continue ; +if (drm_WARN_ON (&i915->drm, data->k >=INTEL_NUM_PIPES (i915))) +return -EINVAL ; + data->streams[data->k].stream_id =intel_conn_to_vcpi (state, connector); data->k++;
@@ -2336,7 +2339,7 @@ intel_hdcp_set_streams(struct intel_digital_port *dig_port, }drm_connector_list_iter_end (&conn_iter); -if (drm_WARN_ON (&i915->drm, data->k >INTEL_NUM_PIPES (i915) || data->k ==0 )) +if (drm_WARN_ON (&i915->drm, !data->k))return -EINVAL ;return 0 ;
Signature · 1 line
2.53.0