Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp2814766rwp; Fri, 14 Jul 2023 11:46:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlHAn/SnrSZvjz83vG1wTR0two+BEQlxp6eyb2ESPCEGw27PaPEgIGR9VRTwVHUfmAxZpGBI X-Received: by 2002:aa7:cf8b:0:b0:51d:8aaf:5adc with SMTP id z11-20020aa7cf8b000000b0051d8aaf5adcmr5158344edx.14.1689360383366; Fri, 14 Jul 2023 11:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689360383; cv=none; d=google.com; s=arc-20160816; b=0RZ430mQh3Uu9Ecm7vZFNbfwHjNDigfI7dPJMrm3pvQnufPp+/hyNGXdu6KvgMtycO onIdu4OYgK1rZRjBvjuuhSs7CcU8qZR7dvULYwUguIOMFG6p/gkj18w4whs42lDIKhS0 TC5bs0Y+zXnjr73qASpJ2v/YrxKR0C+Fe4q8Y79DWD97uGDISfLNihXJKihN/YhAABcp 0JFvJaVBdT/M+CGFk8CAZVcp4IEgFnXFEOob+j9ihdfx7iUQyJySqlTkG3hjEBv3qde/ 54LGHmq4I1pknWpzFwR6qkgKh+1NV/QWxagPBvuSmNaTqTuXWyaLgILL/ejkJhIrXk6N Ww7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=KCsVJp5qnfX7Jssk4LxDYEngrFE1DQACmhXzG+7FPBA=; fh=aMwy5BWk9rMO9VvSTNi8HXbYmVxO2zUxWPYMT5BHdBc=; b=xZ0eS6wLRhcBU5Uhn4zjzRhGC/Pn3mi6jrV20iCxmJc7moWAnM/0HBjNgnYr+huDIY JTWYJaCXxM3kEk9xHTfMLPCpHvALsKm1wdPn5oCHCeS9RMH7BT6f84GzrZSJEOeHSzl0 o3mSw3s/4uVD06/qYPV2mk9UhnfOWeeplevLlvNNg57PcZBGucurnyORvH1cpHeyE865 g0kagYCHQ5JnblWxjSpiXjhQcLrk9XvuocmjrMrXpPaNyyjwc8uxqURy1nk/Hwjpon3k 4YMFqeNWfp5YlS/DxGi5i4HMnCSWUhyRqxfWIKpxNAUDQ6CNfT4vxCGnAJy3RXsxe/rJ x/oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=M2IOJ51R; 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 f2-20020a50ee82000000b0051e24863dd2si9175192edr.377.2023.07.14.11.45.59; Fri, 14 Jul 2023 11:46:23 -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=fail header.i=@embeddedor.com header.s=default header.b=M2IOJ51R; 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 S236448AbjGNSN4 (ORCPT + 99 others); Fri, 14 Jul 2023 14:13:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236551AbjGNSNy (ORCPT ); Fri, 14 Jul 2023 14:13:54 -0400 Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8E6E3A8F for ; Fri, 14 Jul 2023 11:13:33 -0700 (PDT) Received: from eig-obgw-6009a.ext.cloudfilter.net ([10.0.30.184]) by cmsmtp with ESMTP id KM9IqfG6TWU1cKNHeq1S2V; Fri, 14 Jul 2023 18:12:51 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id KNHdqHBNq9oEhKNHeqNAQv; Fri, 14 Jul 2023 18:12:50 +0000 X-Authority-Analysis: v=2.4 cv=WtE4jPTv c=1 sm=1 tr=0 ts=64b19022 a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=WzbPXH4gqzPVN0x6HrNMNA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=ws7JD89P4LkA:10 a=wYkD_t78qR0A:10 a=QX4gbG5DAAAA:8 a=snExLxxF2foCdKK6ZiwA:9 a=QEXdDO2ut3YA:10 a=AbAUZ8qAyYyZVLSsDulk:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=KCsVJp5qnfX7Jssk4LxDYEngrFE1DQACmhXzG+7FPBA=; b=M2IOJ51RbQeLWTH+hDTujo/BcT FNGZuK6zQ5WsYaZHqy6e15H9gS0lstlxNAYl6nkOh9BrObTSI01DAmMJe+kH1UJWGrbwfRjKj3wVZ w+XvmqONUISjI0gjmhcYyH0Shq8M7WpiSJLsFGokjDm3VPjHFrCKY2/l5PKU9/TZ7VaSJR3Kd7u1p uTY2pS3Eb6v6ATGGsMcFTfxWmCiptiGBISG4owzTHEMkGc7IF+IN/YI17JqIeJf2KLdhqg8DfDyiN J+jUs0Lu3d/IszVp55sQ2rf2wsCXnNhmQPTNBlgQqMxittAJ9wmHEw3lkzaCGock2N4feeHIM7DfP vXjo6oYg==; Received: from 187-162-21-192.static.axtel.net ([187.162.21.192]:55814 helo=[192.168.15.8]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1qKNHc-002I2a-1y; Fri, 14 Jul 2023 13:12:49 -0500 Message-ID: <442403e3-317e-8744-3348-dc9823c22074@embeddedor.com> Date: Fri, 14 Jul 2023 12:13:28 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] drm/amdgpu: replace 1-element arrays with flexible arrays Content-Language: en-US To: Alex Deucher , =?UTF-8?Q?Ricardo_Ca=c3=b1uelo?= , "Gustavo A. R. Silva" , Paulo Miguel Almeida Cc: alexander.deucher@amd.com, kernel@collabora.com, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-hardening@vger.kernel.org References: <20230712083137.1080883-1-ricardo.canuelo@collabora.com> From: "Gustavo A. R. Silva" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 187.162.21.192 X-Source-L: No X-Exim-ID: 1qKNHc-002I2a-1y X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 187-162-21-192.static.axtel.net ([192.168.15.8]) [187.162.21.192]:55814 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 3 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfCWN5E+A21o7qlnfGrkwqe1rJilXbZuu6J/t+F6pPCy9b5ncvOpAow3Ggam8SQj0gLA5V8KuW7uNp0uDHCxyLsD7ofYlpkgV2IhcxbOKPfU5Pa+puLBv eIWnjrg7r3JeKBVItBmQHelWnTB4YQDkQMGT1C/0nOj33ZOlm0ohfztMKtJ9y3r9T1CKK+ZLqYvcJnG/Ya5O8tbqPh+ewnHOOY+4qDD7BWbO/+poqWcmq58g X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On 7/12/23 08:12, Alex Deucher wrote: > On Wed, Jul 12, 2023 at 8:04 AM Ricardo Cañuelo > wrote: >> >> UBSAN complains about out-of-bounds array indexes on all 1-element >> arrays defined on this driver: >> >> UBSAN: array-index-out-of-bounds in /home/rcn/work/repos/kernelci/kernelci-core/linux_kernel_mainline/drivers/gpu/drm/amd/amdgpu/../pm/powerplay/hwmgr/processpptables.c:1249:61 >> >> Substitute them with proper flexible arrays. > > + Gustavo, Paulo > > I haven't kept up with the flexible arrays stuff. Is this equivalent > to a zero sized array? We've been bitten by these kind of changes in In terms of size, yes: the size of each array declaration does not contribute to the overall size of its containing structure. However, in these cases, using the DECLARE_FLEX_ARRAY() helper is not required. Simply removing the '1' from the array declaration will suffice. This helper was created to declare flex-array members in unions, as well as in structs that contain no other members aside from the array. In any case, these changes are not complete, as they're only modifying the struct declaration, hence the size of the struct is affected. Now the rest of the code where these structs are involved should be audited and adjusted to accommodate the change in the sizes of the structs. > the past. These structures define the layout of data in a rom image > on the board. If the struct size changes, that could lead to errors > in the code that deals with these structures. > > Alex > Thanks -- Gustavo