Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4187622rdb; Thu, 14 Sep 2023 14:48:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEz8W8bU1we2qAlpoWe4xQmYvCAGHCPWQ2w7woO5ByqgdgNaSIfJdT/mWewVEmqRVZKmFD9 X-Received: by 2002:a17:902:7084:b0:1c0:d17a:bfe9 with SMTP id z4-20020a170902708400b001c0d17abfe9mr5093758plk.46.1694728099013; Thu, 14 Sep 2023 14:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694728098; cv=none; d=google.com; s=arc-20160816; b=fas6Fd+DABhNHQlweWYEVS3kzUfgnwg7lgga448FDym5e5/iWmgyb7fNqgtOBcYVuU VvTDIDfByvJyjZ5M2pofesgyNVl6rBGq6BXq/u2i1ikC60eABLrId7JMKXe7LFf2Pkae 1awfzcbgaQ33+wloqUSxLHB6mHgpwINs8QMqlUivK2fxDvkXiJe+uGt9eQzFrPf+Jivu CeUyHRrdNW9k35jnxUCadLwQGjVRIgM5ttAabFh/yE2faHOp78c0UGerCxFoTuoibbb5 8nh2oIPd9GmHnELCUL18KZZqdKRE4Wrp0ZtH3nHcDthVjtjnw+fM7d0XEtzX+c+9Btwa VFbA== 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:dkim-signature:date; bh=N0uPCiRAY/wk+OsCSsV4Qn54HTT3/j5koYS/Evo6weg=; fh=cP6TXIes1h4OzRdAB/0TANN9KKlfG0aeDhahCJOPreg=; b=cs6KpOSS8VDshDRvvrndj5MGH+YhloywMXquiAbUPEe7Qq4F5OwfM7X6PdNbkFH00A y/1Ytod+SGaVONAscpOa32pZoq2NtgyFxwZyP1ZPnrNsB33OJ7pXzwdwzxX0fYBO62/2 2dPhyFtirZSgswbPesPBYDV6o/Vm7vKQdCX6nxLMaN1fY+cQLdTUAT9Xm0KPfwQLkfp2 QmonxqnCQ0mjvA3/B9wz3ycjp0AxtUJF/1/bw07JQvlwfY5p0frgSuvilbvZoC2+iJZw edWDbp9+VC5NE6mWbIAbawgxjgPQ2NX3gVTTaZj8KJ/t1MUwBmUIvhRkT5XXWvNIOUxt mkRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ndegDqVm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id u5-20020a170902e5c500b001c07eb6236fsi2355840plf.478.2023.09.14.14.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 14:48:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ndegDqVm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 3DFED801B72E; Thu, 14 Sep 2023 12:38:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229486AbjINTiR (ORCPT + 99 others); Thu, 14 Sep 2023 15:38:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjINTiP (ORCPT ); Thu, 14 Sep 2023 15:38:15 -0400 Received: from out-223.mta1.migadu.com (out-223.mta1.migadu.com [IPv6:2001:41d0:203:375::df]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5F7526AB for ; Thu, 14 Sep 2023 12:38:11 -0700 (PDT) Date: Thu, 14 Sep 2023 15:38:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1694720290; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=N0uPCiRAY/wk+OsCSsV4Qn54HTT3/j5koYS/Evo6weg=; b=ndegDqVm/nPasw22OjMVjwca9VMr7jNbEtOPasd7L1k/zvw0P5Q9WzzRcZtq9GAp8lIiph gLp+PIslF+6Mbcp6vptFAp7HyV031HzaJcAZ78wtqC2j8fPAuMbHyoYp6onFOSpnpD8Qqv spmgHAiUf+blNDZy9JcwX+tQRqPhl2A= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Kees Cook Cc: Stephen Rothwell , Linux Next Mailing List , Linux Kernel Mailing List , linux-hardening@vger.kernel.org Subject: Re: linux-next: Tree for Sep 12 (bcachefs) Message-ID: <20230914193807.ozcmylp6n6dsqkbi@moria.home.lan> References: <20230912152645.0868a96a@canb.auug.org.au> <202309131803.6A3C1D05A@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202309131803.6A3C1D05A@keescook> X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 14 Sep 2023 12:38:20 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email On Wed, Sep 13, 2023 at 06:17:00PM -0700, Kees Cook wrote: > On Tue, Sep 12, 2023 at 03:26:45PM +1000, Stephen Rothwell wrote: > > New tree: bcachefs > > Thanks for going through and fixing all the fake flexible array members. > It looks much nicer. :) > > I have some questions about the remaining "markers", for example: > > $ git grep -A8 '\bkey_start\b' -- fs/bcachefs > fs/bcachefs/bcachefs_format.h: __u8 key_start[0]; > ... > fs/bcachefs/bcachefs_format.h- __u8 pad[sizeof(struct bkey) - 3]; > -- > fs/bcachefs/bkey.c: u8 *l = k->key_start; > > Why isn't this just: > > u8 *l = k->pad > > and you can drop the marker? In this case, it's documentation. &k->pad tells us nothing; why is pad significant? k->key_start documents the intent better. > And some seem entirely unused, like all of "struct bch_reflink_v". No, those aren't unused :) bcachefs does the "list of variable size items" a lot - see vstructs.h. start[] is the type of the item being stored, _data is what we use for pointer arithmetic - because we always store sizes in units of u64s, for alignment. > > And some are going to fail at runtime, since they're still zero-sized > and being used as an actual array: > > struct bch_sb_field_journal_seq_blacklist { > struct bch_sb_field field; > > struct journal_seq_blacklist_entry start[0]; > __u64 _data[]; > }; > ... > memmove(&bl->start[i], > &bl->start[i + 1], > sizeof(bl->start[0]) * (nr - i)); > > It looks like you just want a type union for the flexible array. > This can be done like this: > > struct bch_sb_field_journal_seq_blacklist { > struct bch_sb_field field; > > union { > DECLARE_FLEX_ARRAY(struct journal_seq_blacklist_entry, start); > DECLARE_FLEX_ARRAY(__u64, _data); > }; > }; Eesh, why though? Honestly, I'm not a fan of the change to get rid of zero size arrays, this seems to be adding a whole lot of macro layering and indirection for nothing. The only thing a zero size array could possibly be is a flexible array member or a marker, why couldn't we have just kept treating zero size arrays like flexible array members?