Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp530471rwb; Thu, 6 Oct 2022 00:15:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6asKZGdPo7yBVdXUjdkzUp0Fbct7mwsXssndxc4BncNoD1lcOWjHmmAQmEaDQtz+TepO8R X-Received: by 2002:a17:90a:aa8c:b0:205:98b8:f8d5 with SMTP id l12-20020a17090aaa8c00b0020598b8f8d5mr9316923pjq.159.1665040539376; Thu, 06 Oct 2022 00:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665040539; cv=none; d=google.com; s=arc-20160816; b=DeOeLjXImWvQrdcPKO1GdbrZEiPSvjrxCTprdktOVhmlOtGl59IWUaGUQCxnJDjKQs +SQS//qHbZD93qdMXvKxifV6imv3BZ6SBduutZa/YSVLSFvAnH8RuOiJE9yHTPuvW24Q oUVaZOvOuEjT4kVdKk/1QqOwx9Y66vPC7YQyFO1Rk36teWqOMOfeThwYh0dDjG5TDLET nKbQSPji6mhrUOYvGjJxmAkxY+FIojs+3h/+E/peZM2q4J9cao5I3LzCwfIpVj8Xph01 b4+AKj5blbLKzpnURtrhj9QFBVZuUur7RYatxQBOp3TMMdG3Mk9xIzZGH5MipL0R6AoZ 20Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:sender:dkim-signature; bh=8U8sTusKp4JhPNItLtJY5qj5sKhcgHnhEpfdOFEcRoc=; b=tYZTR1HpsZE7qdqAnNYUw4pNOysXU3k8mr6wYpX8s1Ag88geaPpGrHQZyjo/wTLYbz il1jsp7p3RWKk9/gmEN4xMr6CaE6Igvyo32z+FRopyqf9OCQmuMUiZzqrngrsCmd4c8L ybpc1sjfom78RZvvTlwkXIEKV+wx+61k6Y8yRrVP5cgYZ8mMU0YKBLwnzzNJ1YA+uQ4/ SeXCbEPL9LNX6d2MvDFl+jJ5j66j62lJJrT9Vdm8cVds6yKtkN2GK0YJUJccuzEQpcox bb7+wqMt0jD+CiH6POO4O96BP5zkK+TqsA0JmxRO1kTB/2BWJhpgQoyC04xliQz2m2jL UtWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=f0XpWhr7; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t12-20020a63224c000000b00457adf71128si5486817pgm.851.2022.10.06.00.15.27; Thu, 06 Oct 2022 00:15:39 -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=@gmail.com header.s=20210112 header.b=f0XpWhr7; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230087AbiJFGqU (ORCPT + 99 others); Thu, 6 Oct 2022 02:46:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbiJFGqT (ORCPT ); Thu, 6 Oct 2022 02:46:19 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 349CF11A2E for ; Wed, 5 Oct 2022 23:46:18 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id j71so1085269pge.2 for ; Wed, 05 Oct 2022 23:46:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:sender :from:to:cc:subject:date:message-id:reply-to; bh=8U8sTusKp4JhPNItLtJY5qj5sKhcgHnhEpfdOFEcRoc=; b=f0XpWhr7eCwozs4wwkPIJYQ/+vtm+mmphwUBVU9QPj4IA/j45fT8I6SSnjcgQAbu2f zjv5a34R22FYrdrlUz9an2Y3CvArVzV39Hm/vOkSChKJzyX+NhsrblOdC+lfKlZNYQXt 0EePa93WtFh9+sZtD4MCvZm8LJyA753SFTk253mIctN46PaC5cBKum59IVDUcNl8FBC9 giccn+9tT32i8A3PVRLF2bhwSE7ElFI1/Oo3jE8pvB2c/+hw6WBELE3UTSmNZR3kEPBs /NGR5Ov4b0AnxilBLCc4UYmVvCbWEtCN2sM7LWvIhD/5v4coKTfREsIDH9Nsgd9wkMXl fFyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8U8sTusKp4JhPNItLtJY5qj5sKhcgHnhEpfdOFEcRoc=; b=f2Akj0K6Wacrda1bdY20FwHayXMC/X+uKzwvwneOvxgiCkzfTbKAhNYQcA8Z50E7+T eXImfztHqzWOav+7zLmzLgJGsySm57+Y9pjIOH7megdfYZPw0vCmQBkEVc7p0WaLU6ky Nhblpv/sx2S8dZK9nVbE5vKQZUN6n+X3jp5G+424N22eCNDIjTabRJiGu+AyvPGlv52K bBqa0yrCWtgH1zEu9D4TW7SrpWBSnHUPBkzCsoJ6ZCUZxXqbZ4dsyvmvxrumwr2WIF9+ 0s+rSRhXRGEfHJGkQeM8JBk0t1WYkyE7YGcGoTCs+NavsfMM3gEaaq5EQ4Q9G8zMM+SQ TfkQ== X-Gm-Message-State: ACrzQf2ViL/UG2yZjZ2gZZnYwZNa7IkypNUMXVoD0zdH9dWLNf8FjFel uNBhgTN5WO32xpFQpJJh+eA= X-Received: by 2002:a63:211a:0:b0:451:f444:3b55 with SMTP id h26-20020a63211a000000b00451f4443b55mr3111339pgh.60.1665038777524; Wed, 05 Oct 2022 23:46:17 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id p3-20020a1709026b8300b0017f62877604sm5852884plk.66.2022.10.05.23.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 23:46:16 -0700 (PDT) Sender: Guenter Roeck Date: Wed, 5 Oct 2022 23:46:15 -0700 From: Guenter Roeck To: Hamza Mahfooz Cc: linux-kernel@vger.kernel.org, Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , Christian =?iso-8859-1?Q?K=F6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , "Lee, Alvin" , Alex Hung , Pavle Kotarac , Stylon Wang , Aurabindo Pillai , "Leo (Hanghong) Ma" , Hersen Wu , Paul Hsieh , Jimmy Kizito , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: Re: [PATCH] drm/amd/display: fix array-bounds error in dc_stream_remove_writeback() Message-ID: <20221006064615.GA2817657@roeck-us.net> References: <20220927191200.216488-1-hamza.mahfooz@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220927191200.216488-1-hamza.mahfooz@amd.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no 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 On Tue, Sep 27, 2022 at 03:12:00PM -0400, Hamza Mahfooz wrote: > 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. > > Signed-off-by: Hamza Mahfooz With gcc 11.3, this patch doesn't fix a problem, it introduces one. Building csky:allmodconfig ... failed -------------- Error log: 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:83: error: array subscript 1 is above array bounds of 'struct dc_writeback_info[1]' [-Werror=array-bounds] 527 | stream->writeback_info[j] = stream->writeback_info[i]; Building mips:allmodconfig ... failed -------------- Error log: 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:83: 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]; Building arm:allmodconfig ... failed -------------- Error log: 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:83: 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]; Guenter