Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp16041rwi; Sun, 9 Oct 2022 17:32:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Ye6QozrMuXv7PPst6WxHly8SO9Qc2evLUkoZyi2fm6g7kQsifz45lAXwX8zhU+CjOA1rp X-Received: by 2002:a17:90b:1bce:b0:205:e4cd:612 with SMTP id oa14-20020a17090b1bce00b00205e4cd0612mr18106605pjb.32.1665361944462; Sun, 09 Oct 2022 17:32:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665361944; cv=none; d=google.com; s=arc-20160816; b=hiIiz6FgTuQBqAwaGcMOmV7W2MuZmykOA1AZQbhID86fYo+VQrxD9of1354Or5FBYa 1B7gUdYxbHXzqkLoDTeMHVZx/yRTgyeEMwWB05Sz4q8ozy8T4THKpBaMOxG1JmrRuPoH oFX0AoUndeNYq759ZtMFRMJSHq5IaaDKudFZON7DM6Op5LfRVzQKQrZIK4VZr5ZEg1xT 6omahwqAnhS7Wv5dth5mbF2NeqTb1IcETEhGkbWjwbYGRQSbt4gqVRzdGCZCORbbdBJD 6Mdm1x3nN5jwEQij6Pdd8fzY/x2iUXyIYp9P9vVzAidvk1xLaBMEIbQBzf3390zQQjeb IFLA== 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=GbBiB6zukv3vOKRzqSpZPBDcN77pBFtY+9LWoND4V2Y=; b=mollNV5usNzQRmPjx6oVLNeN48JlVHmGUzITOigR9FZpIjhwxiLmKL85E8aZ3IkHBk GK02wG0xINUG4GQgxsXh6MFYJkzrEx6xW9EW+e438yexnxnKJtQCIT67VTkX8gTDojpW 5kIIAny/ZuuOmcENRUrd07+mz3xhME083P2pooyEXyMJ1wUQy4F+UF3owGQsqnHUaa79 swsTUNQ38LDU9xg3xxditoP6AYeZMPXTsSRbN9M6B1JRh6q2MfXPJfYbzF06dyTpav+X LJdVnSq0u2ojhZwqv9kNQraX5lpFE6i31zCKCot6DPVm8+v6c0N8xjpDBxRHr0qnedeg MT3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="J/fn43i6"; 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 bg17-20020a056a02011100b0041bd0985ea9si10567588pgb.671.2022.10.09.17.32.13; Sun, 09 Oct 2022 17:32:24 -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="J/fn43i6"; 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 S233121AbiJJA2x (ORCPT + 99 others); Sun, 9 Oct 2022 20:28:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232931AbiJJAXz (ORCPT ); Sun, 9 Oct 2022 20:23:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9662C106; Sun, 9 Oct 2022 16:57:46 -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 F1B3360C27; Sun, 9 Oct 2022 23:57:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45AD7C43141; Sun, 9 Oct 2022 23:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665359865; bh=53Kx9p1JunFuha73ZI0vJqmUjAwzpNLy4hgWi6hm6KY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J/fn43i6Z0se8LFm9tq1eCLcBQKjStxe574WxUQ5odmjkfI3avVxDZaV/ltoELFAK JNOsrJsxfQyys4Y9DTDU6Xz0FDRe5i0jOqZf+0LBVKzEVnrMgbEGbiEPw076I/26Qi TsrT88zGZVr0rshkrG1elmpYWmrqccdV6Gr4s3p1fihA6U8nZZSsafoddEToCkWWp0 MLx5hK52mBAOgwAkKvrjQgHziuTbw3vaqcbgshSM/RI3wzcBrBJ1sanvM1we+B4eKe VcnH0nhC/JDUYCeNEEQtbFhd3s0hWh5eWf/zb4v8/7j0q6g/lJ3SniCCz86H7ViInG /jRsuRs4JZSNw== 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.4 14/14] drm/amd/display: fix array-bounds error in dc_stream_remove_writeback() Date: Sun, 9 Oct 2022 19:57:10 -0400 Message-Id: <20221009235710.1231937-14-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009235710.1231937-1-sashal@kernel.org> References: <20221009235710.1231937-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 bb09243758fe..95d36cb79e28 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c @@ -458,7 +458,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