From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33A4A418372; Fri, 7 Aug 2026 14:56:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114613; cv=none; b=LaBXgq2/3ogfs+IJc6ejyKKZC/dwPgo3bMHQMWW5Kc2ro292RRYSHAaCQ5M/g7s/ucv59nraFm34yWw3XZ076JoPVSlQEMmcsVKCy1U8nm97gNNuKrKB6eATbcDRDxrEAH6HA015us7EtLZktswyekLyefxSclkcgMCYoa+G98A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114613; c=relaxed/simple; bh=neaO/ul91aR7iOz3fPFIGFIs4Bjnf+iRqoEfe7xwMZk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rQIznYEZ38S5cOpgUuJumFoWEj3cdq7/g/wQcchFKxyaXFNUy8kxVF9mTLmgiqBZuRWOoi32Dj8bhTpEyg/ug6pEDEebyQo4SXhumKM25VddVR9+DHiJNxZrnu271/58ub1IRvbcv/J04JhbZjfkGG6Sc8hxU1+NRa4rp6H7KpY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nukFkviD; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nukFkviD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 406881F00A3A; Fri, 7 Aug 2026 14:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786114610; bh=Y41e+evg6o97u7MW9Sysg3+IWCfaDZfPoz5J0BLZy8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nukFkviD+1RoJRYs/8ZdvD5AdURBEllKuISL+0kIteEmVIJfQbiKEiEwqEJYKzF6q 8LNkIsownHqQxBuMFjr0pegQk7amoylK2CbXA64CZs5/TNj/BFT27ib4opBsMX3SKn XlALPgFMhYwV+bDWNmsAG1yHnZ53lmm17LOAzGYk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Martin Hodo , Anshuman Gupta , Suraj Kandpal , Jani Nikula , Joonas Lahtinen , Sasha Levin Subject: [PATCH 6.12 325/337] drm/i915/hdcp: check streams[] bounds before overflow Date: Fri, 7 Aug 2026 16:38:48 +0200 Message-ID: <20260807143425.584452053@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260807143418.516897842@linuxfoundation.org> References: <20260807143418.516897842@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jani Nikula [ 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. Reported-by: Martin Hodo Fixes: e03187e12cae ("drm/i915/hdcp: MST streams support in hdcp port_data") Cc: stable@vger.kernel.org # v5.12+ Cc: Anshuman Gupta Cc: Suraj Kandpal Reviewed-by: Suraj Kandpal Link: https://patch.msgid.link/20260625170304.1104723-1-jani.nikula@intel.com Signed-off-by: Jani Nikula (cherry picked from commit 9284ab3b6e776c315883ac2611283d263c9460fd) Signed-off-by: Joonas Lahtinen Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/display/intel_hdcp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/i915/display/intel_hdcp.c +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c @@ -129,6 +129,9 @@ intel_hdcp_required_content_stream(struc 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++; @@ -139,7 +142,7 @@ intel_hdcp_required_content_stream(struc } 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; /*