From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F9F9C4320E for ; Fri, 27 Aug 2021 16:17:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0097560EFF for ; Fri, 27 Aug 2021 16:17:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245505AbhH0QS3 (ORCPT ); Fri, 27 Aug 2021 12:18:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234297AbhH0QS2 (ORCPT ); Fri, 27 Aug 2021 12:18:28 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACE04C061757 for ; Fri, 27 Aug 2021 09:17:39 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id s29so1271839pfw.5 for ; Fri, 27 Aug 2021 09:17:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=PpE3AD8eCxkq5tJ/76g5xkddl9cPG+SrwUT4D+L1j9M=; b=PTuUn80HoLhaJHYCP7XyumnxfjHBpHlaOH8dvc9A+77jDWBiFwpof2Hbr0Ax+XMQ7X Uq95i61xse+X9GVAAmvNI7JtRH1mxT+CkyhUQCoW8SPNHyP1XyWWar/ZkHusyNYzyhTk m/FgwR5I6I6GjP+eCQEc2GAtdCKzCkL3ZCrvo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PpE3AD8eCxkq5tJ/76g5xkddl9cPG+SrwUT4D+L1j9M=; b=Rw3ITXj/kQjMHLMkea752hPpHtjou8AE9npakS4nC3on/gRR4h7IjKzFM1409BQxcD ajYrI4Y506Q7gm4ZywtqtVuDNO98WwK1uF3SC9P1Erg/1OSsoIdmHiAy9D4EPob/xKZc Ha6MnDdmqPBGDAxbYxo0JIz9h1lY6s97GJNBiAVIYGWAva5mZ0NtYoNcZRkfs+6XyHB2 KytRhZpD9D+JPZ+i5bX4i6FaRyRDKttceXRNRIn4MiYdIJS0C8er/SnJ/T21BNh2Q/LU n7kUJy3Ig9vN3i8TYhjfaWCNqefJ0V9HSKTtU3KonMns+ZWvL5QVW311XW/Uay+lkpqm 1Dew== X-Gm-Message-State: AOAM531y5T+83EzfO1y0wr5JghbBJHEavea5ObAwUrnHALoYODqKemFu ArfiPW5wmOz2oczILOsGIG0KUw== X-Google-Smtp-Source: ABdhPJw/t8YOl1nXk3QdPbWpwbPMUYpww4D2dqTkc0FJGW4t+oJnaLp5x7c5LQiINxHw5PXRusXtVw== X-Received: by 2002:a63:79c7:: with SMTP id u190mr8361038pgc.355.1630081059098; Fri, 27 Aug 2021 09:17:39 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id y67sm6883595pfg.218.2021.08.27.09.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 09:17:38 -0700 (PDT) Date: Fri, 27 Aug 2021 09:17:37 -0700 From: Kees Cook To: Marc Kleine-Budde Cc: linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , Arnd Bergmann , Ayush Sawal , Vinay Kumar Yadav , Rohit Maheshwari , Herbert Xu , "David S. Miller" , Kalle Valo , Jakub Kicinski , Stanislaw Gruszka , Luca Coelho , "James E.J. Bottomley" , "Martin K. Petersen" , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Johannes Berg , Mordechay Goodstein , Lee Jones , Wolfgang Grandegger , Arunachalam Santhanam , Vincent Mailhol , Mikulas Patocka , linux-crypto@vger.kernel.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, linux-can@vger.kernel.org, bpf@vger.kernel.org, Rasmus Villemoes , Keith Packard , Dan Williams , Daniel Vetter , clang-built-linux@googlegroups.com, linux-hardening@vger.kernel.org Subject: Re: [PATCH v2 2/5] treewide: Replace open-coded flex arrays in unions Message-ID: <202108270915.B4DD070AF@keescook> References: <20210826050458.1540622-1-keescook@chromium.org> <20210826050458.1540622-3-keescook@chromium.org> <20210826062452.jekmoo43f4xu5jxk@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210826062452.jekmoo43f4xu5jxk@pengutronix.de> Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Thu, Aug 26, 2021 at 08:24:52AM +0200, Marc Kleine-Budde wrote: > [...] > BTW: Is there opportunity for conversion, too? > > | drivers/net/can/peak_canfd/peak_pciefd_main.c:146:32: warning: array of flexible structures Untested potential solution: diff --git a/drivers/net/can/peak_canfd/peak_pciefd_main.c b/drivers/net/can/peak_canfd/peak_pciefd_main.c index 1df3c4b54f03..efa2b5a52bd7 100644 --- a/drivers/net/can/peak_canfd/peak_pciefd_main.c +++ b/drivers/net/can/peak_canfd/peak_pciefd_main.c @@ -143,7 +143,11 @@ struct pciefd_rx_dma { __le32 irq_status; __le32 sys_time_low; __le32 sys_time_high; - struct pucan_rx_msg msg[]; + /* + * with "msg" being pciefd_irq_rx_cnt(priv->irq_status)-many + * variable-sized struct pucan_rx_msg following. + */ + __le32 msg[]; } __packed __aligned(4); /* Tx Link record */ @@ -327,7 +331,7 @@ static irqreturn_t pciefd_irq_handler(int irq, void *arg) /* handle rx messages (if any) */ peak_canfd_handle_msgs_list(&priv->ucan, - rx_dma->msg, + (struct pucan_rx_msg *)rx_dma->msg, pciefd_irq_rx_cnt(priv->irq_status)); /* handle tx link interrupt (if any) */ It's not great, but it's also not strictly a flex array, in the sense that since struct pucan_rx_msg is a variable size, the compiler cannot reason about the size of struct pciefd_rx_dma based only on the irq_status encoding... -- Kees Cook From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00109C432BE for ; Fri, 27 Aug 2021 16:18:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B867D60E78 for ; Fri, 27 Aug 2021 16:18:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B867D60E78 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=m183iKd/A1cNYfhEDwrdiw3fbiIprVA21h+4NVSNc34=; b=abvAVxFtWi8/OR mgqeVhxN6dmyBDmNb5wqP9bZeoW/FvnQuJ5Lek0xj4/hrHrIwfev6QfMpa63C70XMJ6hqDdG8cN+g xix6unpdik0FVQnRiAVDahaJETw2pFIynKSjrbaDHY91WXkh7sv5UTwjZfTBKAxozX8TJb0ZNuBk0 kdJ6FY9tg7wIuIkv+Z4g9NOCnRXl+9jDwEnVetrhYC4qr6c2TKODAD20Qq+3Ue15cypAJ9Ha2e6zx ztf6zaDudAqsziSA5rFvyYCqYluci8JYIcwFA2olx/MdYGR0gAy+6kMdyMLTMCpMUsjmpRvmNeUDi y8c83FbSlKK5zjU9b06g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJeY7-00Cja8-Om; Fri, 27 Aug 2021 16:17:47 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mJeY2-00CjZC-4P for ath10k@lists.infradead.org; Fri, 27 Aug 2021 16:17:46 +0000 Received: by mail-pg1-x52e.google.com with SMTP id x4so6397860pgh.1 for ; Fri, 27 Aug 2021 09:17:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=PpE3AD8eCxkq5tJ/76g5xkddl9cPG+SrwUT4D+L1j9M=; b=PTuUn80HoLhaJHYCP7XyumnxfjHBpHlaOH8dvc9A+77jDWBiFwpof2Hbr0Ax+XMQ7X Uq95i61xse+X9GVAAmvNI7JtRH1mxT+CkyhUQCoW8SPNHyP1XyWWar/ZkHusyNYzyhTk m/FgwR5I6I6GjP+eCQEc2GAtdCKzCkL3ZCrvo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PpE3AD8eCxkq5tJ/76g5xkddl9cPG+SrwUT4D+L1j9M=; b=SmoP+cgCoxkKedI7OglpI7HX/f4ndmkgqvzl0FGcVBQGEPe+zVa5ugncqStAyqKaFq fS7Ro/QPvyiujfKEbYLMjCWI0T1SevLKVfxxzv/P0P97fXvoOsttKVhIReDqYEAWTMYp wR21xqf9vLcR+lw6PXuyrVUlk7DWTtyXuEpk9KYDWzdyb43PAMrMUebkaqHPeEbfay6A cL7PgohwKo6qRV1W7jVAcsOlSJw2IXHwdgh/+DbKCcIZxD3lpSeQAqXP6cRr8WQrwfNF vO42op2SeZXTnx9BSPu5nLVB7ylMoEQdaqNIoknuQc3AwBr01pgr+f4xTrW2YiEQ/Grk vcOA== X-Gm-Message-State: AOAM530p+fWhM89JQHemYc3K4cj0RvdxU600T/ELRSfOE0LceWxo1OPe kYt2VLp1WQZBiYB3PKiOLC+hKg== X-Google-Smtp-Source: ABdhPJw/t8YOl1nXk3QdPbWpwbPMUYpww4D2dqTkc0FJGW4t+oJnaLp5x7c5LQiINxHw5PXRusXtVw== X-Received: by 2002:a63:79c7:: with SMTP id u190mr8361038pgc.355.1630081059098; Fri, 27 Aug 2021 09:17:39 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id y67sm6883595pfg.218.2021.08.27.09.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 09:17:38 -0700 (PDT) Date: Fri, 27 Aug 2021 09:17:37 -0700 From: Kees Cook To: Marc Kleine-Budde Cc: linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , Arnd Bergmann , Ayush Sawal , Vinay Kumar Yadav , Rohit Maheshwari , Herbert Xu , "David S. Miller" , Kalle Valo , Jakub Kicinski , Stanislaw Gruszka , Luca Coelho , "James E.J. Bottomley" , "Martin K. Petersen" , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Johannes Berg , Mordechay Goodstein , Lee Jones , Wolfgang Grandegger , Arunachalam Santhanam , Vincent Mailhol , Mikulas Patocka , linux-crypto@vger.kernel.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, linux-can@vger.kernel.org, bpf@vger.kernel.org, Rasmus Villemoes , Keith Packard , Dan Williams , Daniel Vetter , clang-built-linux@googlegroups.com, linux-hardening@vger.kernel.org Subject: Re: [PATCH v2 2/5] treewide: Replace open-coded flex arrays in unions Message-ID: <202108270915.B4DD070AF@keescook> References: <20210826050458.1540622-1-keescook@chromium.org> <20210826050458.1540622-3-keescook@chromium.org> <20210826062452.jekmoo43f4xu5jxk@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210826062452.jekmoo43f4xu5jxk@pengutronix.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210827_091742_240542_3E737797 X-CRM114-Status: GOOD ( 14.57 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "ath10k" Errors-To: ath10k-bounces+ath10k=archiver.kernel.org@lists.infradead.org On Thu, Aug 26, 2021 at 08:24:52AM +0200, Marc Kleine-Budde wrote: > [...] > BTW: Is there opportunity for conversion, too? > > | drivers/net/can/peak_canfd/peak_pciefd_main.c:146:32: warning: array of flexible structures Untested potential solution: diff --git a/drivers/net/can/peak_canfd/peak_pciefd_main.c b/drivers/net/can/peak_canfd/peak_pciefd_main.c index 1df3c4b54f03..efa2b5a52bd7 100644 --- a/drivers/net/can/peak_canfd/peak_pciefd_main.c +++ b/drivers/net/can/peak_canfd/peak_pciefd_main.c @@ -143,7 +143,11 @@ struct pciefd_rx_dma { __le32 irq_status; __le32 sys_time_low; __le32 sys_time_high; - struct pucan_rx_msg msg[]; + /* + * with "msg" being pciefd_irq_rx_cnt(priv->irq_status)-many + * variable-sized struct pucan_rx_msg following. + */ + __le32 msg[]; } __packed __aligned(4); /* Tx Link record */ @@ -327,7 +331,7 @@ static irqreturn_t pciefd_irq_handler(int irq, void *arg) /* handle rx messages (if any) */ peak_canfd_handle_msgs_list(&priv->ucan, - rx_dma->msg, + (struct pucan_rx_msg *)rx_dma->msg, pciefd_irq_rx_cnt(priv->irq_status)); /* handle tx link interrupt (if any) */ It's not great, but it's also not strictly a flex array, in the sense that since struct pucan_rx_msg is a variable size, the compiler cannot reason about the size of struct pciefd_rx_dma based only on the irq_status encoding... -- Kees Cook _______________________________________________ ath10k mailing list ath10k@lists.infradead.org http://lists.infradead.org/mailman/listinfo/ath10k