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 1438946D0BD; Thu, 20 Aug 2026 16:34:13 +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=1787243654; cv=none; b=QtsipzjbMCX5dDAgBn7GmGNa0j7oL5j9McLPBSVJ5yVImDvli8Rd1RPIt7vJ9eK9i7IYXkK0Ne8Ybf5M03at5b97qUWhO+Q/WgHy0bwytobKbDr7Sh19soV+pwqnBo8t7qoUzoY9PTJyK9utm7f0GpI1Aooiruv5c8YfEYS+sA8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787243654; c=relaxed/simple; bh=SEF9YMdfyjwjC6fdDoPhW1i8ApWUdMjtGpAc2GnKhUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lYXR8FfN4PDG8rAKmj5Th1qIq5QwTs4TPFedrL8jyVS1tRR7bE8GjHOGM7TjSccNs+7NC74aGxZ3vXT6ZHXzbhlzGESdE/1uAIjMbvr1MG1lgd55Mpm9wbMtL1huakQnAM4aJwDqtxlg/tojnTpemfFU/ixji2B7yeW0ox7fKMo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Xp0s53Yn; 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="Xp0s53Yn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E7E71F000E9; Thu, 20 Aug 2026 16:34:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787243653; bh=WMRkb6Lhe9O8YV01KWd8HmFEhJ7XbBmFeuWPB6Kg1rQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Xp0s53Yn9QFNPP9CR2oOkCYT7s1oeYKyr7ThveJ4B52V1MeM7Jjt5FPQPvVq4zJD2 rLLer9P0e7Dgak7tdQDxVerBbDzGw3XyPJLQcecUfzCGFO5cPMm8T6RSx2w5M83GOe jPw8Wr5iiN72FkvnxnLQ/dnXeb9px3vmIUSCfI00= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ashutosh Desai , Lyude Paul , Sasha Levin Subject: [PATCH 5.15 170/272] drm/dp/mst: fix OOB reads in remote DPCD/I2C sideband reply parsers Date: Thu, 20 Aug 2026 16:55:54 +0200 Message-ID: <20260820145236.460659450@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145231.229664293@linuxfoundation.org> References: <20260820145231.229664293@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ashutosh Desai [ Upstream commit 1a8f537f5a1eeac941f262fe73078d6b08ba83c0 ] drm_dp_sideband_parse_remote_dpcd_read() reads num_bytes from the raw message and then unconditionally does: memcpy(bytes, &raw->msg[idx], num_bytes); without checking that idx + num_bytes <= raw->curlen. raw->msg[] is 256 bytes; if a malicious or misbehaving MST hub sets num_bytes larger than the remaining payload, the memcpy reads past the received data into whatever follows in raw->msg[]. drm_dp_sideband_parse_remote_i2c_read_ack() has the same flaw (noted with a /* TODO check */ comment since the code was introduced). Fix both functions by using a single combined check (idx + num_bytes > curlen) before each memcpy. Since num_bytes is u8, it is always >= 0, so this strictly subsumes the simpler idx > curlen form and no separate step is needed. Fixes: ad7f8a1f9ced ("drm/helper: add Displayport multi-stream helper (v0.6)") Cc: # v3.17+ Signed-off-by: Ashutosh Desai Reviewed-by: Lyude Paul [added missing fixes tag] Signed-off-by: Lyude Paul Link: https://patch.msgid.link/20260510201733.2882224-1-ashutoshdesai993@gmail.com Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/drm_dp_mst_topology.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -870,7 +870,7 @@ static bool drm_dp_sideband_parse_remote goto fail_len; repmsg->u.remote_dpcd_read_ack.num_bytes = raw->msg[idx]; idx++; - if (idx > raw->curlen) + if (idx + repmsg->u.remote_dpcd_read_ack.num_bytes > raw->curlen) goto fail_len; memcpy(repmsg->u.remote_dpcd_read_ack.bytes, &raw->msg[idx], repmsg->u.remote_dpcd_read_ack.num_bytes); @@ -906,7 +906,9 @@ static bool drm_dp_sideband_parse_remote goto fail_len; repmsg->u.remote_i2c_read_ack.num_bytes = raw->msg[idx]; idx++; - /* TODO check */ + if (idx + repmsg->u.remote_i2c_read_ack.num_bytes > raw->curlen) + goto fail_len; + memcpy(repmsg->u.remote_i2c_read_ack.bytes, &raw->msg[idx], repmsg->u.remote_i2c_read_ack.num_bytes); return true; fail_len: