From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 806EE1EB22; Tue, 13 Feb 2024 17:36:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707845814; cv=none; b=BOslIf+tXSHtx07hHQ0WtFFS13ReZoEOudpLHtq04Of5wcqREq/99M+XxR4ZU5IVSBZy6mo5TEWV861aZedEZSUpi//7mnWwopPbgDy5ERnJ4Hn0rwF3ilaYkqE+yrbhxWQ+PAIOPpiC/OUSWczJVvkBnsZFOdw2akVnFOVdh2k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707845814; c=relaxed/simple; bh=+qDK9M73/x9Uogp0GuTcIrrqh51XnPa5kc9uSZU9/Rs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mUke2bfM+uftRBprA5/LXDcLlEYr4OTpYXzrKmqzcJARktd083d+8s6Gx3xJfHED7EDCwVjYKYPU3SzmQDvpjAWdkg3pRXFHyQTSWDAwuTNAW8HrWsx6sxUkzbAIC+A2Y6U/U5DpWqBGAb7Ifa/I0ldmWv41ko0h9/IXIRJclNA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=r5/ygZRh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="r5/ygZRh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00007C433C7; Tue, 13 Feb 2024 17:36:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1707845814; bh=+qDK9M73/x9Uogp0GuTcIrrqh51XnPa5kc9uSZU9/Rs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r5/ygZRhJcNObPL87ggOQKEj/h+KGOIbNIiV8+xQ9aYEi01ebsYtrp0yqE2bHP17c Xvi8HvjPEgccmRuyzh7UqMjeeQ9hSvMy0B6vR1orKwr2D4hpqBS8cxVj/aptek6S4B Ift4YEjU3yraSSI49K7s8qMXYMc6ia3NFrjqwE6s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Roman Li , Rodrigo Siqueira , Aurabindo Pillai , Srinivasan Shanmugam , Roman Li , Alex Deucher , Sasha Levin Subject: [PATCH 6.7 064/124] drm/amd/display: Implement bounds check for stream encoder creation in DCN301 Date: Tue, 13 Feb 2024 18:21:26 +0100 Message-ID: <20240213171855.606776403@linuxfoundation.org> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240213171853.722912593@linuxfoundation.org> References: <20240213171853.722912593@linuxfoundation.org> User-Agent: quilt/0.67 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.7-stable review patch. If anyone has any objections, please let me know. ------------------ From: Srinivasan Shanmugam [ Upstream commit 58fca355ad37dcb5f785d9095db5f748b79c5dc2 ] 'stream_enc_regs' array is an array of dcn10_stream_enc_registers structures. The array is initialized with four elements, corresponding to the four calls to stream_enc_regs() in the array initializer. This means that valid indices for this array are 0, 1, 2, and 3. The error message 'stream_enc_regs' 4 <= 5 below, is indicating that there is an attempt to access this array with an index of 5, which is out of bounds. This could lead to undefined behavior Here, eng_id is used as an index to access the stream_enc_regs array. If eng_id is 5, this would result in an out-of-bounds access on the stream_enc_regs array. Thus fixing Buffer overflow error in dcn301_stream_encoder_create reported by Smatch: drivers/gpu/drm/amd/amdgpu/../display/dc/resource/dcn301/dcn301_resource.c:1011 dcn301_stream_encoder_create() error: buffer overflow 'stream_enc_regs' 4 <= 5 Fixes: 3a83e4e64bb1 ("drm/amd/display: Add dcn3.01 support to DC (v2)") Cc: Roman Li Cc: Rodrigo Siqueira Cc: Aurabindo Pillai Signed-off-by: Srinivasan Shanmugam Reviewed-by: Roman Li Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c index f3b75f283aa2..ce04caf35d80 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c @@ -999,7 +999,7 @@ static struct stream_encoder *dcn301_stream_encoder_create(enum engine_id eng_id vpg = dcn301_vpg_create(ctx, vpg_inst); afmt = dcn301_afmt_create(ctx, afmt_inst); - if (!enc1 || !vpg || !afmt) { + if (!enc1 || !vpg || !afmt || eng_id >= ARRAY_SIZE(stream_enc_regs)) { kfree(enc1); kfree(vpg); kfree(afmt); -- 2.43.0