From patchwork Tue Nov 28 18:22:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 170910 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp4131282vqx; Tue, 28 Nov 2023 10:23:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcA2neCdjDBjuJYhcGrKrCr8UCsjGw+Azb1hsYA45Cpec6m+qq6DB7TzKAS0qg11nermgK X-Received: by 2002:a05:6a20:244b:b0:18c:fa:17f7 with SMTP id t11-20020a056a20244b00b0018c00fa17f7mr19604774pzc.46.1701195786676; Tue, 28 Nov 2023 10:23:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701195786; cv=none; d=google.com; s=arc-20160816; b=TOzAf246vJTyZz08UdNW28EjCEP3ZSH3N0BZkiuhsm2fzgeyEIN+HGSj8IRSBae51s GAPnSocrOTfjGewKOt4YKTOM7wa8g6KkZCRyLjrPsj6BouhB6+g+1PY9AqOPNsP1NmJK 1TaJunFIQINyGkYU9SDon3E6YwG+yLkTZV+zjaR3VM5nwDmucE5jNbT3rVCHTWabCSfs tUk2IB+fB/H+pXaAUN8RQZmBKYS/6vQhhM22CYWpdXjAvlnUcekh3HXgxiF+fbFAUk7k slfZuGcoOv8PdayCrYKqpp4yudumWWxtbB4/kDgqFiJ0G30njG4K2TFnfbaQZkeH4lC8 wAGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=p84VailvbBHhd063cBmkI0KcGfO6UfzFvTvOcLPPAmU=; fh=a9DUR2BkWEeP0cACbiaI2xwcDvDVC/gt15O7/cIFKdk=; b=JmkapfTVEKGkliyqriOen3Ivx+1hxHKyzXQldBTQGIE1ST9BAsNNmG9iE207rZfVt6 2S48g7+rTFBBKUSjfAbpj+FQ0+NObvSog+cRtvj+uWMOUeQsSpue97a3R7/h1rKiH3RV HJqU+bSrBcL8wkDXE2rBEg5Q3ocvyS59kl63wedvFllkMej4sdc7kE90fvaUO8WDVLnb NknNocJlTUchGKUOPIzpA7tC2/0YBoIS22UR9yPVc058K2e3tZFL4oWO6tTiNqSPxcDT a2/Nuj8bpSbkR2qqBfvanqszJeGoeQ03o4KOVbarvY54WGB0/uzd9zqSeZ99UGb3/IcH dKJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="CI/yy0Um"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id u13-20020a056a00158d00b006cdcd785487si86070pfk.304.2023.11.28.10.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 10:23:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="CI/yy0Um"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id EF6918051B37; Tue, 28 Nov 2023 10:23:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345605AbjK1SWx (ORCPT + 99 others); Tue, 28 Nov 2023 13:22:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344800AbjK1SWw (ORCPT ); Tue, 28 Nov 2023 13:22:52 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8BF01BF for ; Tue, 28 Nov 2023 10:22:58 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93A02C433C8; Tue, 28 Nov 2023 18:22:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701195778; bh=cmXLCB6F0Jpxz1dOg+AMECgAoHmZ4123tddCyGivbbE=; h=Date:From:To:Cc:Subject:From; b=CI/yy0Umi/PpzvRt1FlzsEM7nnYvzJwqE3X5Im7HmTJPnRHmYCTu0qONSLZUIPjxz J5F3P6b0AlI5jyvlE2NiIVMHqRXZQwCj/j5JWL8rk2GAv5FugU/wU2EzqPrkqth0l4 yOxmslgztj+TA7ToNy4NQURj1YZZVKLKTpq6VbgRpFxBUz8Hv1xC0CAlN1/0Tacsxs FLtFehfOUXF3Pz0Lcutrq2hjsyifyOdE6rn+OWTjD7hE2JBbG/V5sl8SDKgK4xKdw0 k671ZdXQY73LErhZ22jaDgyYdY9XU7FyYalV5va1aE4UbOrezjSC3izJnDSijy9mJ9 pfJkPvZmLQzJg== Date: Tue, 28 Nov 2023 12:22:55 -0600 From: "Gustavo A. R. Silva" To: Kent Overstreet , Brian Foster Cc: linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] bcachefs: Replace zero-length arrays with flexible-array members Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 28 Nov 2023 10:23:02 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783833072821630511 X-GMAIL-MSGID: 1783833072821630511 Fake flexible arrays (zero-length and one-element arrays) are deprecated, and should be replaced by flexible-array members. So, replace zero-length arrays with flexible-array members in multiple structures. Signed-off-by: Gustavo A. R. Silva Reviewed-by: Kees Cook --- fs/bcachefs/bcachefs_ioctl.h | 4 ++-- fs/bcachefs/io_read.c | 2 +- fs/bcachefs/move.c | 2 +- fs/bcachefs/replicas_types.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/bcachefs/bcachefs_ioctl.h b/fs/bcachefs/bcachefs_ioctl.h index 44ba7a87aea7..43822c17297c 100644 --- a/fs/bcachefs/bcachefs_ioctl.h +++ b/fs/bcachefs/bcachefs_ioctl.h @@ -276,7 +276,7 @@ struct bch_ioctl_fs_usage { __u32 replica_entries_bytes; __u32 pad; - struct bch_replicas_usage replicas[0]; + struct bch_replicas_usage replicas[]; }; /* @@ -313,7 +313,7 @@ struct bch_ioctl_dev_usage_v2 { __u32 bucket_size; __u64 nr_buckets; - struct bch_ioctl_dev_usage_type d[0]; + struct bch_ioctl_dev_usage_type d[]; }; /* diff --git a/fs/bcachefs/io_read.c b/fs/bcachefs/io_read.c index 3281c4dd1d52..4c9eaf7cea8d 100644 --- a/fs/bcachefs/io_read.c +++ b/fs/bcachefs/io_read.c @@ -80,7 +80,7 @@ struct promote_op { struct bpos pos; struct data_update write; - struct bio_vec bi_inline_vecs[0]; /* must be last */ + struct bio_vec bi_inline_vecs[]; /* must be last */ }; static const struct rhashtable_params bch_promote_params = { diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c index c5518a866276..5a693c3e2ed2 100644 --- a/fs/bcachefs/move.c +++ b/fs/bcachefs/move.c @@ -81,7 +81,7 @@ struct moving_io { struct data_update write; /* Must be last since it is variable size */ - struct bio_vec bi_inline_vecs[0]; + struct bio_vec bi_inline_vecs[]; }; static void move_free(struct moving_io *io) diff --git a/fs/bcachefs/replicas_types.h b/fs/bcachefs/replicas_types.h index 030324078bba..ac90d142c4e8 100644 --- a/fs/bcachefs/replicas_types.h +++ b/fs/bcachefs/replicas_types.h @@ -21,7 +21,7 @@ struct replicas_delta_list { u64 nr_inodes; u64 persistent_reserved[BCH_REPLICAS_MAX]; struct {} memset_end; - struct replicas_delta d[0]; + struct replicas_delta d[]; }; #endif /* _BCACHEFS_REPLICAS_TYPES_H */