[Devel] [PATCH VZ10 v2] fs/fuse kio: replace zero-length array with flexible array syntax

Liu Kui kui.liu at virtuozzo.com
Mon May 18 07:20:59 MSK 2026


With FORTIFY_SOURCE, memcpy to a zero-length array field is flagged
as field-spanning, causing kernel warning. Switch to the C99 flexible
array [] syntax to fix this.

Changes:
v1:
 - _data_buf[0] -> _data_buf[] in struct krpc_completion
 - sync_resp[0] -> sync_resp[] in struct pcs_cs_iohdr
 - nodes[0] -> nodes[] in struct pcs_cs_map_prop
 - cs[0] -> cs[] in struct pcs_cs_list
 - cs[0] -> cs[] in struct pcs_ioc_getmap

v2:
 - move struct krpc_completion to the end of struct krpc_req

Link: https://virtuozzo.atlassian.net/browse/VSTOR-130548

Signed-off-by: Liu Kui <kui.liu at virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_cs_prot.h | 4 ++--
 fs/fuse/kio/pcs/pcs_ioctl.h   | 2 +-
 fs/fuse/kio/pcs/pcs_krpc.h    | 6 +++---
 fs/fuse/kio/pcs/pcs_map.h     | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_cs_prot.h b/fs/fuse/kio/pcs/pcs_cs_prot.h
index c72066de7be4..c524d28b551e 100644
--- a/fs/fuse/kio/pcs/pcs_cs_prot.h
+++ b/fs/fuse/kio/pcs/pcs_cs_prot.h
@@ -79,7 +79,7 @@ struct pcs_cs_iohdr {
 		u32			fiemap_count;	/* Used only in FIEMAP request, limit on number of extents to return */
 	};
 	struct pcs_cs_sync_data	sync;		/* Filled in all requests and responses */
-	struct pcs_cs_sync_resp sync_resp[0];	/* Used only in response to write/sync */
+	struct pcs_cs_sync_resp sync_resp[];	/* Used only in response to write/sync */
 } __attribute__((aligned(8)));
 
 static inline int pcs_cs_use_aligned_io(u32 storage_version)
@@ -171,7 +171,7 @@ struct pcs_cs_map_prop {
 	u16			chain_nodes;
 	u16			reserved;
 	u32			nnodes;
-	struct pcs_cs_node_desc	nodes[0];
+	struct pcs_cs_node_desc	nodes[];
 } __attribute__((aligned(8)));
 
 #define CS_OBJ_UNKNOWN		-1
diff --git a/fs/fuse/kio/pcs/pcs_ioctl.h b/fs/fuse/kio/pcs/pcs_ioctl.h
index fb22cf8a01b0..07a87d6507f3 100644
--- a/fs/fuse/kio/pcs/pcs_ioctl.h
+++ b/fs/fuse/kio/pcs/pcs_ioctl.h
@@ -74,7 +74,7 @@ struct pcs_ioc_getmap
 	/* TODO: cs array is only for OUT ? */
 	u32			cs_cnt;		/* The number of CS (including root) entries that follows */
 	u32			cs_max;		/* Max number of CS (including root) entries requested */
-	struct pcs_cs_info	cs[0];		/* Array of CS including root */
+	struct pcs_cs_info	cs[];		/* Array of CS including root */
 };
 
 #define PCS_IOC_NOCSUMONREAD	_IOW('V',3,u32)
diff --git a/fs/fuse/kio/pcs/pcs_krpc.h b/fs/fuse/kio/pcs/pcs_krpc.h
index 6a090ef66185..92dae58ef43b 100644
--- a/fs/fuse/kio/pcs/pcs_krpc.h
+++ b/fs/fuse/kio/pcs/pcs_krpc.h
@@ -99,7 +99,7 @@ struct krpc_completion {
 
 	void		*private;
 	int			data_len;
-	u8			_data_buf[0];
+	u8			_data_buf[];
 };
 
 #define KRPC_MAX_DATA_PAGES			256
@@ -129,11 +129,11 @@ struct krpc_req {
 	int nr_data_bvecs;
 	struct bio_vec data_bvecs[KRPC_MAX_DATA_PAGES];
 
-	struct krpc_completion completion;
-
 	u32			    gen;
 	struct llist_node	    llist_link;
 	struct pcs_krpc_ioc_sendmsg iocmsg;
+
+	struct krpc_completion completion;
 };
 
 static inline u32 pcs_krpc_msg_size(u32 size, u8 flags)
diff --git a/fs/fuse/kio/pcs/pcs_map.h b/fs/fuse/kio/pcs/pcs_map.h
index bf8a0e7177d0..788a8cb16d8e 100644
--- a/fs/fuse/kio/pcs/pcs_map.h
+++ b/fs/fuse/kio/pcs/pcs_map.h
@@ -127,7 +127,7 @@ struct pcs_cs_list
 	int			write_timeout;
 	int			nsrv;
 	PCS_MAP_VERSION_T	version;		/* version inherented from map */
-	struct pcs_cs_record	cs[0];
+	struct pcs_cs_record	cs[];
 };
 
 /* TODO, LOCKING!!!!!
-- 
2.39.5 (Apple Git-154)



More information about the Devel mailing list