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 5104B5FF15; Tue, 13 Feb 2024 17:24:19 +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=1707845059; cv=none; b=FYfd1MFmuuvUAQLXjI9D+uYPyas7+q9nqRg8yyOI1Oesh2fF88vLi7RTzhVjdeKhdgJpZHi3O/oruokHQDHHkYNYbqx2Nlzi7CUiIHypLH6AZpeCFEdPCGmDFAASDz5cFlSozDWKWOnXsME4qGMCYZn8zkEs8TEXjVGs4/L0Dvg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707845059; c=relaxed/simple; bh=gU1/CUZjFJe1SvYdIcqH9+xhLf1c7ZiALBliIWyc/AY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bp44SAu2O1RB9sIrgTfSNJxS5tP19sSYrhtY8TAr1U1lO2OerHv3EeLnWzRKQ01DnOQ3zs4Ota/apLlCr6YtRJ2PBz+Z/yrUiFeLvuUWF2Bygx8ogkS4XR5zF46iK6MygbFe8S7Wl37Gy6aVtbpntcSLh7Y+tgrqPOe6BjAtqgk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AW8LeTuw; 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="AW8LeTuw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAC67C433C7; Tue, 13 Feb 2024 17:24:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1707845059; bh=gU1/CUZjFJe1SvYdIcqH9+xhLf1c7ZiALBliIWyc/AY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AW8LeTuw+/rfCluDC2skkIYYYaHe1MjOSXC3QubywGTpOPlT4gLXCl+Zooe+SbnLj YKS6T/p7uY7mxKhDNSREqT5b4TD2TiTSMxUGRJ+D+9uaDGlGoSPyVPDAmlrjST2own AgNcNvpFp8TAN/A98H7qXqqekE5FK1636Ck71pUU= 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.1 35/64] drm/amd/display: Implement bounds check for stream encoder creation in DCN301 Date: Tue, 13 Feb 2024 18:21:21 +0100 Message-ID: <20240213171845.852112250@linuxfoundation.org> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240213171844.702064831@linuxfoundation.org> References: <20240213171844.702064831@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.1-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 f04595b750ab..5ec3f50a72ac 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c @@ -1014,7 +1014,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