* [PATCH][next] bcachefs: Replace zero-length arrays with flexible-array members
@ 2023-11-28 18:22 Gustavo A. R. Silva
2023-11-29 20:15 ` Kees Cook
2023-11-29 21:12 ` Kent Overstreet
0 siblings, 2 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2023-11-28 18:22 UTC (permalink / raw)
To: Kent Overstreet, Brian Foster
Cc: linux-bcachefs, linux-kernel, Gustavo A. R. Silva,
linux-hardening
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 <gustavoars@kernel.org>
---
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 */
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH][next] bcachefs: Replace zero-length arrays with flexible-array members
2023-11-28 18:22 [PATCH][next] bcachefs: Replace zero-length arrays with flexible-array members Gustavo A. R. Silva
@ 2023-11-29 20:15 ` Kees Cook
2023-11-29 20:25 ` Gustavo A. R. Silva
2023-11-29 21:12 ` Kent Overstreet
1 sibling, 1 reply; 4+ messages in thread
From: Kees Cook @ 2023-11-29 20:15 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Kent Overstreet, Brian Foster, linux-bcachefs, linux-kernel,
linux-hardening
On Tue, Nov 28, 2023 at 12:22:55PM -0600, Gustavo A. R. Silva wrote:
> 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 <gustavoars@kernel.org>
These look like straight-forward conversions. Thanks!
Reviewed-by: Kees Cook <keescook@chromium.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] bcachefs: Replace zero-length arrays with flexible-array members
2023-11-29 20:15 ` Kees Cook
@ 2023-11-29 20:25 ` Gustavo A. R. Silva
0 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2023-11-29 20:25 UTC (permalink / raw)
To: Kees Cook, Gustavo A. R. Silva
Cc: Kent Overstreet, Brian Foster, linux-bcachefs, linux-kernel,
linux-hardening
On 11/29/23 14:15, Kees Cook wrote:
> On Tue, Nov 28, 2023 at 12:22:55PM -0600, Gustavo A. R. Silva wrote:
>> 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 <gustavoars@kernel.org>
>
> These look like straight-forward conversions. Thanks!
Yep, these also fix a buch of -Warray-bounds warnings reported
by 0-day:
https://lore.kernel.org/lkml/202311290720.TzNYq81c-lkp@intel.com/
>
> Reviewed-by: Kees Cook <keescook@chromium.org>
>
Thanks!
--
Gustavo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] bcachefs: Replace zero-length arrays with flexible-array members
2023-11-28 18:22 [PATCH][next] bcachefs: Replace zero-length arrays with flexible-array members Gustavo A. R. Silva
2023-11-29 20:15 ` Kees Cook
@ 2023-11-29 21:12 ` Kent Overstreet
1 sibling, 0 replies; 4+ messages in thread
From: Kent Overstreet @ 2023-11-29 21:12 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Brian Foster, linux-bcachefs, linux-kernel, linux-hardening,
Kees Cook
On Tue, Nov 28, 2023 at 12:22:55PM -0600, Gustavo A. R. Silva wrote:
> 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 <gustavoars@kernel.org>
There are some ZLAs I hadn't converted because they led to new warnings
- in particular, array of flexible members.
I don't think that applies to any of the ones you changed
(replicas_delta_list, maybe?) - but it's something we need to figure
out if we're getting serious about this.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-11-29 21:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-28 18:22 [PATCH][next] bcachefs: Replace zero-length arrays with flexible-array members Gustavo A. R. Silva
2023-11-29 20:15 ` Kees Cook
2023-11-29 20:25 ` Gustavo A. R. Silva
2023-11-29 21:12 ` Kent Overstreet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox