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=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_2 autolearn=no 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 0BB25C4727C for ; Thu, 1 Oct 2020 08:12:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A9BB4208B8 for ; Thu, 1 Oct 2020 08:12:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730862AbgJAIMe convert rfc822-to-8bit (ORCPT ); Thu, 1 Oct 2020 04:12:34 -0400 Received: from mslow2.mail.gandi.net ([217.70.178.242]:39014 "EHLO mslow2.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbgJAIMe (ORCPT ); Thu, 1 Oct 2020 04:12:34 -0400 Received: from relay1-d.mail.gandi.net (unknown [217.70.183.193]) by mslow2.mail.gandi.net (Postfix) with ESMTP id 42DF23AB62A; Thu, 1 Oct 2020 08:12:32 +0000 (UTC) X-Originating-IP: 91.224.148.103 Received: from xps13 (unknown [91.224.148.103]) (Authenticated sender: miquel.raynal@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id ECF2124000D; Thu, 1 Oct 2020 08:12:07 +0000 (UTC) Date: Thu, 1 Oct 2020 10:12:06 +0200 From: Miquel Raynal To: Jann Horn Cc: "Gustavo A. R. Silva" , Stefan Agner , Lucas Stach , Richard Weinberger , Vignesh Raghavendra , Thierry Reding , Jonathan Hunter , linux-mtd@lists.infradead.org, linux-tegra@vger.kernel.org, kernel list , linux-hardening@vger.kernel.org Subject: Re: [PATCH][next] mtd: rawnand: Replace one-element array with flexible-array member Message-ID: <20201001101206.6e4beea7@xps13> In-Reply-To: References: <20200930210824.GA12277@embeddedor> <20200930213634.GA12855@embeddedor> Organization: Bootlin X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Hi Jann, Jann Horn wrote on Thu, 1 Oct 2020 00:32:24 +0200: > On Wed, Sep 30, 2020 at 11:30 PM Gustavo A. R. Silva > wrote: > > On Wed, Sep 30, 2020 at 11:10:43PM +0200, Jann Horn wrote: > > > On Wed, Sep 30, 2020 at 11:02 PM Gustavo A. R. Silva > > > wrote: > > > > There is a regular need in the kernel to provide a way to declare having > > > > a dynamically sized set of trailing elements in a structure. Kernel code > > > > should always use “flexible array members”[1] for these cases. The older > > > > style of one-element or zero-length arrays should no longer be used[2]. > > > > > > But this is not such a case, right? Isn't this a true fixed-size > > > array? It sounds like you're just changing it because it > > > pattern-matched on "array of length 1 at the end of a struct". > > > > Yeah; I should have changed that 'dynamically' part of the text above > > a bit. However, as I commented in the text below, in the case that more > > CS IDs are needed (let's wait for the maintainers to comment on this...) > > in the future, this change makes the code more maintainable, as for > > the allocation part, the developer would only have to update the CS_N > > macro to the number of CS IDs that are needed. > > But in that case, shouldn't you change it to "int cs[CS_N]" and get > rid of the struct_size() stuff? I do agree with Jann, I think it's best to consider this a fixed-size array for now. If we ever want to extend the number of supported CS, there is much more rework involved anyway. Thanks, Miquèl 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=-5.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=no 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 D6BA5C4727C for ; Thu, 1 Oct 2020 08:12:44 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 848A5208B8 for ; Thu, 1 Oct 2020 08:12:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="aq58oKfD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 848A5208B8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID: Subject: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=gNa3Wzw2tpWCPzFKm8/AT0A9jzCJmdZQA5seNHOYtyc=; b=aq58oKfDH100LSbRbQAsupmSF XfHhcBJ6MPsuugMXK/ZwclXZFibG3jUGBPPCscP0PPfJqv/Oz19ihGac5/2dj/3A02fwFrsElFZEB UVqYcdWdVkMXJrovA3IjM5jGPW6bgcvxF3uSmk+05o2fyTMt/qglPyPKWmQ4ZDx7FXG/TIDewctI5 QUxF7UpDzPPevmeJDjHZrtLkvXGODnKR9wqAx533FZtQmB84H5NEP1hLv51X2+zUsWfOIg/sgFoW6 kpCxTNTbjd/vmPfA7Ma0SqaeO0O1o2jUhifGc+l/wQP3ZEhVppdzz7b12w0+2DcH9VHlWIM/Sw2H1 16UMwnchg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNthH-0008Bd-On; Thu, 01 Oct 2020 08:12:15 +0000 Received: from relay1-d.mail.gandi.net ([217.70.183.193]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNthE-0008Au-VQ for linux-mtd@lists.infradead.org; Thu, 01 Oct 2020 08:12:14 +0000 X-Originating-IP: 91.224.148.103 Received: from xps13 (unknown [91.224.148.103]) (Authenticated sender: miquel.raynal@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id ECF2124000D; Thu, 1 Oct 2020 08:12:07 +0000 (UTC) Date: Thu, 1 Oct 2020 10:12:06 +0200 From: Miquel Raynal To: Jann Horn Subject: Re: [PATCH][next] mtd: rawnand: Replace one-element array with flexible-array member Message-ID: <20201001101206.6e4beea7@xps13> In-Reply-To: References: <20200930210824.GA12277@embeddedor> <20200930213634.GA12855@embeddedor> Organization: Bootlin X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201001_041213_114455_B4E373C7 X-CRM114-Status: GOOD ( 20.37 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lucas Stach , Vignesh Raghavendra , Richard Weinberger , "Gustavo A. R. Silva" , Stefan Agner , Jonathan Hunter , Thierry Reding , linux-mtd@lists.infradead.org, linux-hardening@vger.kernel.org, linux-tegra@vger.kernel.org, kernel list Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org SGkgSmFubiwKCkphbm4gSG9ybiA8amFubmhAZ29vZ2xlLmNvbT4gd3JvdGUgb24gVGh1LCAxIE9j dCAyMDIwIDAwOjMyOjI0ICswMjAwOgoKPiBPbiBXZWQsIFNlcCAzMCwgMjAyMCBhdCAxMTozMCBQ TSBHdXN0YXZvIEEuIFIuIFNpbHZhCj4gPGd1c3Rhdm9hcnNAa2VybmVsLm9yZz4gd3JvdGU6Cj4g PiBPbiBXZWQsIFNlcCAzMCwgMjAyMCBhdCAxMToxMDo0M1BNICswMjAwLCBKYW5uIEhvcm4gd3Jv dGU6ICAKPiA+ID4gT24gV2VkLCBTZXAgMzAsIDIwMjAgYXQgMTE6MDIgUE0gR3VzdGF2byBBLiBS LiBTaWx2YQo+ID4gPiA8Z3VzdGF2b2Fyc0BrZXJuZWwub3JnPiB3cm90ZTogIAo+ID4gPiA+IFRo ZXJlIGlzIGEgcmVndWxhciBuZWVkIGluIHRoZSBrZXJuZWwgdG8gcHJvdmlkZSBhIHdheSB0byBk ZWNsYXJlIGhhdmluZwo+ID4gPiA+IGEgZHluYW1pY2FsbHkgc2l6ZWQgc2V0IG9mIHRyYWlsaW5n IGVsZW1lbnRzIGluIGEgc3RydWN0dXJlLiBLZXJuZWwgY29kZQo+ID4gPiA+IHNob3VsZCBhbHdh eXMgdXNlIOKAnGZsZXhpYmxlIGFycmF5IG1lbWJlcnPigJ1bMV0gZm9yIHRoZXNlIGNhc2VzLiBU aGUgb2xkZXIKPiA+ID4gPiBzdHlsZSBvZiBvbmUtZWxlbWVudCBvciB6ZXJvLWxlbmd0aCBhcnJh eXMgc2hvdWxkIG5vIGxvbmdlciBiZSB1c2VkWzJdLiAgCj4gPiA+Cj4gPiA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