Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp546727rdb; Tue, 31 Oct 2023 15:11:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/zgvsK9HbBuBTYKBomsfphxMtY0CW/6D7EU+RUzAFP0xEcwWujGTuCGGNP3DFapBc5g0r X-Received: by 2002:a05:6a00:2b8c:b0:6bf:15fb:4b32 with SMTP id dv12-20020a056a002b8c00b006bf15fb4b32mr1010139pfb.8.1698790314125; Tue, 31 Oct 2023 15:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698790314; cv=none; d=google.com; s=arc-20160816; b=vLsbka7elxEGcFcm8eMdNbeZWYK8FZXJBWMCQGthakoomTa+1eM6VoVzehMytQMMqJ YPBHaHmfFdWf/qj8IEtQ60qLooSPk8vViYtWE1hWJXZFx11u7C0pvgA1pocqxtEWkzmK uWJA1z3qSVYK4jD2zKdxozhH5dI6ezmoRv8ds2OMMSTfIC3sgKo3r+kuQVSIyeVK2q+8 hm2N96wwid37QHaIFMmCIT4B5lcYmN/fRV/LABK0jg3VUmhnW2eabqfoWwSBovRSw4JN s0AFBEs0miuLYsxoyuN/VaoGq7WevKsmVIKrPP/lCDhrjsDdoPPjzNSwLFJNWfNgz36n 1ONQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:dkim-signature:date; bh=lKAVh/PtZlDLOODYkBclJPD12VobypZ8XYn2N5TwM0Y=; fh=q6mBMz1DqfvAIbJa+2IsZfMNPYoZ20ag+wensdP9bqM=; b=JaLr9fXuMxbMDGCyczkudP/GfgqaTID9BMKVnwXEyp0cflA7eQmO5GZ2ASleAnxSFs OpCGY8iyLLWXfEt3S/hG6DEAQwU6wVmKyFy/0kP6x4/3NWh3mSRIXDK97ma6z7ujbEnr mxmff2IM7/33JzTnN7KqezIC27jfhuSjbNZMVkRJZsj/NYllk8ygcc6VVTholdG+ict5 xHgTWXjCex0r/g2BprmvspKX3Scws//6qykow1uoNc2bGGGH8K1tWNvdYH/IFR00zZxc YX7wp+1Lh2bRHuenZR9E1P+A48la9AhBI8d8Mwyz6h6rnVNcmIdUB4Nyf/YKqvJVVjNH rg4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=EKow9nLE; 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 m189-20020a633fc6000000b0059cd78384fdsi1699559pga.222.2023.10.31.15.11.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 15:11:54 -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=EKow9nLE; 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 6F23680EA795; Tue, 31 Oct 2023 15:11:51 -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 S230186AbjJaWLm (ORCPT + 99 others); Tue, 31 Oct 2023 18:11:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232160AbjJaWLl (ORCPT ); Tue, 31 Oct 2023 18:11:41 -0400 Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [IPv6:2001:41d0:203:375::ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BC22EA; Tue, 31 Oct 2023 15:11:38 -0700 (PDT) Date: Tue, 31 Oct 2023 18:11:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1698790296; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lKAVh/PtZlDLOODYkBclJPD12VobypZ8XYn2N5TwM0Y=; b=EKow9nLEka6mdz9vObOv4R1e1yPz6EF26QrdHb0wJDZgC/HmRs4GW6EMbTlM8ijQuRg0uw 6StUyghZAKPEhWeYUBiPVMG9dLHOVawELNkufQDdzWOh65fJ5dpFg2sQG2r0W1AFo6xUkO UznDbkQSLAr5Rjt9UrINNuQ7xvFCzMc= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: John Stoffel Cc: Geert Uytterhoeven , Linus Torvalds , linux-bcachefs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook Subject: Re: [GIT PULL] bcachefs for v6.7 Message-ID: <20231031221126.5wejfggu7gg2y3n4@moria.home.lan> References: <25921.30263.150556.245226@quad.stoffel.home> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <25921.30263.150556.245226@quad.stoffel.home> X-Migadu-Flow: FLOW_OUT 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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]); Tue, 31 Oct 2023 15:11:51 -0700 (PDT) On Tue, Oct 31, 2023 at 05:48:39PM -0400, John Stoffel wrote: > > Using latest HEAD from linux git (commit > 5a6a09e97199d6600d31383055f9d43fbbcbe86f (HEAD -> master, > origin/master, origin/HEAD), and the following config, I get this > failure when compiling on x86_64 Debian Bullseye (11): > > > CC fs/bcachefs/btree_io.o > In file included from fs/bcachefs/btree_io.c:11: > fs/bcachefs/btree_io.c: In function ‘bch2_btree_post_write_cleanup’: > fs/bcachefs/btree_update_interior.h:274:36: error: array subscript 0 is outside the bounds of an interior zero-length array ‘struct bkey_packed[0]’ [-Werror=zero-length-bounds] > 274 | __bch_btree_u64s_remaining(c, b, &bne->keys.start[0]); > | ^~~~~~~~~~~~~~~~~~~ > In file included from fs/bcachefs/bcachefs.h:206, > from fs/bcachefs/btree_io.c:3: > fs/bcachefs/bcachefs_format.h:2344:21: note: while referencing ‘start’ > 2344 | struct bkey_packed start[0]; > | ^~~~~ > In file included from fs/bcachefs/btree_io.c:11: > fs/bcachefs/btree_io.c: In function ‘bch2_btree_init_next’: > fs/bcachefs/btree_update_interior.h:274:36: error: array subscript 0 is outside the bounds of an interior zero-length array ‘struct bkey_packed[0]’ [-Werror=zero-length-bounds] > 274 | __bch_btree_u64s_remaining(c, b, &bne->keys.start[0]); > | ^~~~~~~~~~~~~~~~~~~ > In file included from fs/bcachefs/bcachefs.h:206, > from fs/bcachefs/btree_io.c:3: > fs/bcachefs/bcachefs_format.h:2344:21: note: while referencing ‘start’ > 2344 | struct bkey_packed start[0]; > | ^~~~~ > cc1: all warnings being treated as errors > make[4]: *** [scripts/Makefile.build:243: fs/bcachefs/btree_io.o] Error 1 > make[3]: *** [scripts/Makefile.build:480: fs/bcachefs] Error 2 > make[2]: *** [scripts/Makefile.build:480: fs] Error 2 > make[1]: *** [/local/src/kernel/git/linux/Makefile:1913: .] Error 2 > make: *** [Makefile:234: __sub-make] Error 2 It seems gcc 10 complains in situations gcc 11 does not. I've got the following patch running through my testing automation now: -- >8 -- From: Kent Overstreet Date: Tue, 31 Oct 2023 18:05:22 -0400 Subject: [PATCH] bcachefs: Fix build errors with gcc 10 gcc 10 seems to complain about array bounds in situations where gcc 11 does not - curious. This unfortunately requires adding some casts for now; we may investigate getting rid of our __u64 _data[] VLA in a future patch so that our start[0] members can be VLAs. Reported-by: John Stoffel Signed-off-by: Kent Overstreet diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h index 29b000c6b7e1..5b44598b9df9 100644 --- a/fs/bcachefs/bcachefs_format.h +++ b/fs/bcachefs/bcachefs_format.h @@ -1617,9 +1617,7 @@ struct journal_seq_blacklist_entry { struct bch_sb_field_journal_seq_blacklist { struct bch_sb_field field; - - struct journal_seq_blacklist_entry start[0]; - __u64 _data[]; + struct journal_seq_blacklist_entry start[]; }; struct bch_sb_field_errors { diff --git a/fs/bcachefs/btree_trans_commit.c b/fs/bcachefs/btree_trans_commit.c index 8140b6e6e9a6..32693f7c6221 100644 --- a/fs/bcachefs/btree_trans_commit.c +++ b/fs/bcachefs/btree_trans_commit.c @@ -681,7 +681,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags, BCH_JSET_ENTRY_overwrite, i->btree_id, i->level, i->old_k.u64s); - bkey_reassemble(&entry->start[0], + bkey_reassemble((struct bkey_i *) entry->start, (struct bkey_s_c) { &i->old_k, i->old_v }); } @@ -689,7 +689,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags, BCH_JSET_ENTRY_btree_keys, i->btree_id, i->level, i->k->k.u64s); - bkey_copy(&entry->start[0], i->k); + bkey_copy((struct bkey_i *) entry->start, i->k); } trans_for_each_wb_update(trans, wb) { @@ -697,7 +697,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags, BCH_JSET_ENTRY_btree_keys, wb->btree, 0, wb->k.k.u64s); - bkey_copy(&entry->start[0], &wb->k); + bkey_copy((struct bkey_i *) entry->start, &wb->k); } if (trans->journal_seq) diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index d029e0348c91..89ada89eafe7 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -2411,7 +2411,7 @@ void bch2_journal_entry_to_btree_root(struct bch_fs *c, struct jset_entry *entry r->level = entry->level; r->alive = true; - bkey_copy(&r->key, &entry->start[0]); + bkey_copy(&r->key, (struct bkey_i *) entry->start); mutex_unlock(&c->btree_root_lock); } diff --git a/fs/bcachefs/btree_update_interior.h b/fs/bcachefs/btree_update_interior.h index 5e0a467fe905..d92b3cf5f5e0 100644 --- a/fs/bcachefs/btree_update_interior.h +++ b/fs/bcachefs/btree_update_interior.h @@ -271,7 +271,7 @@ static inline struct btree_node_entry *want_new_bset(struct bch_fs *c, struct btree_node_entry *bne = max(write_block(b), (void *) btree_bkey_last(b, bset_tree_last(b))); ssize_t remaining_space = - __bch_btree_u64s_remaining(c, b, &bne->keys.start[0]); + __bch_btree_u64s_remaining(c, b, bne->keys.start); if (unlikely(bset_written(b, bset(b, t)))) { if (remaining_space > (ssize_t) (block_bytes(c) >> 3)) diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index f73338f37bf1..9600b8083175 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -226,7 +226,7 @@ static int journal_replay_entry_early(struct bch_fs *c, if (entry->u64s) { r->level = entry->level; - bkey_copy(&r->key, &entry->start[0]); + bkey_copy(&r->key, (struct bkey_i *) entry->start); r->error = 0; } else { r->error = -EIO;