Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp63053rwi; Sun, 9 Oct 2022 18:32:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7XvxcQmxytTuueIMl/ypC+5uK09caYtepTBoZURsjPkduEQ+1bcFdXSiAIN5MedLyOoyDj X-Received: by 2002:a17:90a:f190:b0:20a:a8b1:b199 with SMTP id bv16-20020a17090af19000b0020aa8b1b199mr29168661pjb.83.1665365573679; Sun, 09 Oct 2022 18:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665365573; cv=none; d=google.com; s=arc-20160816; b=rv9wjWVNb8gv52TIm0w/5jS8J9enKo7JrjEFHGWJC6lRYQCHlc36rfmg2H7bdJDKc5 MdqD6lVJJ3LLWIuqeiIj8aijUXJzheknJgsxwI+ow67Vfof1u+rOQ/Ejd3XK5EnAJOEr V4P32/QWnRBGw+4hFYHr05txMPC8a/anrAC/9eC5XinfUnaO7Y41xDo5uIZRW+YpVe1H 1JEdWQntfHd40rKk3POfnt0gXijZb3aoj5xin8LCQ7d+1WqyOv1mjkgfDzgYJaTUPrIs KZpqsEXi20L6L0nhFbDjsAKyyMBMrsCbERWxRzNJyY/J0Iu4HMfNVMH4mivDVjuQFaae 5jNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PmPPXquvKf+kx0hK2nnOCMBDYGAEToBGHFNXjwQ91cA=; b=r4rsdw0iZptq/KlCox2xGbFDjyBHs7lSPWwUWIq9xlA/wLkZk2MXZkszH6JUk+BxMC mtrnTdNJd7dCMAvn5KE0OFYt8ZBh+CE4fZKuDX+Q+oKGjYlXJbtO6hx4XuowNrUlTqts gc/HhVZc0JPpGGwsaJqeuF6udzTeBsDqfdRUoRr0ObFAqu1uG8wiP+qTbFiEl9CpM7Lo c254APfycmmd52gOpdSMX90sMHzqKfr3f74LyA9xYGr7gTocSg3QFCpjd6sxinWsgpWM LZU0X/Ioo52CmGbZ7+e62kO9mR706XqMpcjm2Jwass2NiQF0wixy6c2bHFcKiK4vSxl3 /rhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PbF2rZNH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w3-20020a170902d10300b001713df0c8b2si8964993plw.213.2022.10.09.18.32.40; Sun, 09 Oct 2022 18:32:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PbF2rZNH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232919AbiJJA1d (ORCPT + 99 others); Sun, 9 Oct 2022 20:27:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232866AbiJJAXt (ORCPT ); Sun, 9 Oct 2022 20:23:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3209B237F1; Sun, 9 Oct 2022 16:57:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C33FB60CF5; Sun, 9 Oct 2022 23:57:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14352C433C1; Sun, 9 Oct 2022 23:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665359830; bh=Pz9ZsItQ1uNJr7qgBMr/+xmodQ2vsCKTlDPfXXmZrXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PbF2rZNH6PokwlDlA5ycKC+Q45KNnAN8muOQLT5E6pM/U0yFpZQfZx69PSWL0O9/S /b3mSW6krKAV6/D36K5G3EHnZ4fh91FiHFzd5ZMOM5gsc8meJV98ZzX+fhfqYaPpHA ac/eiP5jOOA5W+DCiZyuXTGeID/4pgoAxqxi900zkRnwxmjQgqCuFkOYXmaxKyvW2k NWGZf+dJSNQC/e07T8Y/UGM5qjNcTBkHg1se7QsliP4iwq0CfvDYAgmEdUW6NfgqxE lMpzlWHnDYFTkXi49P36NYq9TbpqnY35qHEfoG9QuJSrzbF/vJfPGQrbRZBbh+vpER NInEXe/Wo37mw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hamza Mahfooz , Aurabindo Pillai , Alex Deucher , Sasha Levin , harry.wentland@amd.com, sunpeng.li@amd.com, Rodrigo.Siqueira@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, Alvin.Lee2@amd.com, Pavle.Kotarac@amd.com, alex.hung@amd.com, hanghong.ma@amd.com, hersenwu@amd.com, paul.hsieh@amd.com, Jimmy.Kizito@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.10 22/22] drm/amd/display: fix array-bounds error in dc_stream_remove_writeback() Date: Sun, 9 Oct 2022 19:55:40 -0400 Message-Id: <20221009235540.1231640-22-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009235540.1231640-1-sashal@kernel.org> References: <20221009235540.1231640-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hamza Mahfooz [ Upstream commit 5d8c3e836fc224dfe633e41f7f2856753b39a905 ] Address the following error: drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c: In function ‘dc_stream_remove_writeback’: drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c:527:55: error: array subscript [0, 0] is outside array bounds of ‘struct dc_writeback_info[1]’ [-Werror=array-bounds] 527 | stream->writeback_info[j] = stream->writeback_info[i]; | ~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from ./drivers/gpu/drm/amd/amdgpu/../display/dc/dc.h:1269, from ./drivers/gpu/drm/amd/amdgpu/../display/dc/inc/core_types.h:29, from ./drivers/gpu/drm/amd/amdgpu/../display/dc/basics/dc_common.h:29, from drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c:27: ./drivers/gpu/drm/amd/amdgpu/../display/dc/dc_stream.h:241:34: note: while referencing ‘writeback_info’ 241 | struct dc_writeback_info writeback_info[MAX_DWB_PIPES]; | Currently, we aren't checking to see if j remains within writeback_info[]'s bounds. So, add a check to make sure that we aren't overflowing the buffer. Reviewed-by: Aurabindo Pillai Signed-off-by: Hamza Mahfooz Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c index d48fd87d3b95..867b8b66293a 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c @@ -491,7 +491,7 @@ bool dc_stream_remove_writeback(struct dc *dc, } /* remove writeback info for disabled writeback pipes from stream */ - for (i = 0, j = 0; i < stream->num_wb_info; i++) { + for (i = 0, j = 0; i < stream->num_wb_info && j < MAX_DWB_PIPES; i++) { if (stream->writeback_info[i].wb_enabled) { if (i != j) /* trim the array */ -- 2.35.1