Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1459986pxb; Fri, 27 Aug 2021 09:18:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeqYWArhXCzHO7LAYOVv/hkCmwqPh4LmV4tpAPSaqkoOQufh9Wmzj5nYn+AOQ/plIyjlow X-Received: by 2002:a17:906:a18f:: with SMTP id s15mr10577057ejy.269.1630081113397; Fri, 27 Aug 2021 09:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630081113; cv=none; d=google.com; s=arc-20160816; b=So2EpK5e7xIX/UTMYWqMVG9bPXb/HcuwNKx0Gp7EMVtnaMe8YsnwMhW469+rOammn3 Uy61/EugcMwhjmIXpaYkaIqasHa8AiI1LGTRwekuZsEXPT1qJDu2PFY3fKRYtE8y/gMD RoLJlEtoZ33PTSgrjdkzWjdqevTMOiWEG9i3QclhPrM/aB6PzorO/R7BJ1HcHwD7Ayv3 d6hLChg2GQLCtysVBQlpMedA08sFdxAVu2KI5Xb30jp8UtgZx7/2QWWPaKWqimnzfWhl uHKmxxuxSTmfFgyG//226eyigC9KGMnJEBei+bdzOOkMNSCC6q9zVAe6BkidyeEiO0Iy ZeBA== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PpE3AD8eCxkq5tJ/76g5xkddl9cPG+SrwUT4D+L1j9M=; b=vgj8RX+M0GhYEZAd97EZCmhlTtwTpoI+WbDq6SfwptqfwcQzUwXdiBZtMNdeHgDn5M g36KtMyebXqp4NQ1kw2glhyQlg546N2x/q+exKZASj4AQHn0dwp2vIoKsoj4wssjbEkf HbIV6MQfnOcm+KY6WRITW1H66vQ2wOLcNz2pcDCt2XvhXus07SwqIJ3n7u0rzLjutpCC 4dpiV+2NuduBHbt1HRs+mwlIiidLXApOaYpJj7vgTCdHFBCiaMnktXfCFVTSr5C4mo3J 9ZILzxH8JNxADECgzDLrZVrKXDXRiAUMyosQNLcFBTDvjThbsEdLUgnRVelG5k4gs8F1 cm9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PTuUn80H; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n15si6113918ejl.353.2021.08.27.09.17.44; Fri, 27 Aug 2021 09:18:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PTuUn80H; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245497AbhH0QS3 (ORCPT + 99 others); Fri, 27 Aug 2021 12:18:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234192AbhH0QS2 (ORCPT ); Fri, 27 Aug 2021 12:18:28 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD8E5C0613D9 for ; Fri, 27 Aug 2021 09:17:39 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id w7so5208088pgk.13 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=EkwN+fkJ/0cQSw7TuB3iMC14qwBFvjUyqCUL1wREcbijZ5xwe7OuwcZLCeOfTG/bGS fV9p/kg3QCPRE5tr0e0f7zo6NRSEZtmwDNFQwQh0FgqUBftbrNxHVNMd5cFmCL7MgEri 4K8NevEX0EsjEkuP++aCq8w9YEaa13WN4GguVi6toXGCupdrlzDX9l841vj2EjXzYQZU MRPxDTdepycjASobAIJLcT70PbrRvu3OnzvcAaDp5hVie189YIr5Dbr9Ph3KCR6eSQL5 +WlbDetynJTdOEaDZ1VKOz3ASDkwiuWq4mTyqMDC/j1syjDLqA4xEU1lCvps/ZkpIRoS d+Qg== X-Gm-Message-State: AOAM532mFnJejj/+9zAEVFOIrfAqmQ8Kn123L1X6PYspaRiLYYl4DBdy eUFx62eHnAklP4mifaetIIAblg== 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: linux-crypto@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