diff mbox series

ksmbd: fix flexible_array.cocci warnings

Message ID 20211104045718.30388-1-guozhengkui@vivo.com (mailing list archive)
State New, archived
Headers show
Series ksmbd: fix flexible_array.cocci warnings | expand

Commit Message

Guo Zhengkui Nov. 4, 2021, 4:57 a.m. UTC
Fix following coccicheck warnings:
./fs/ksmbd/xxxxxx: WARNING use flexible-array member instead.

There is a regular need in the kernel to provide a way to declare
having a dynamically sized set of trailing elements in a structure.
Kernel code should always use “flexible array members” for these
cases. The older style of one-element or zero-length arrays should
no longer be used.

Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
---
 fs/ksmbd/ksmbd_netlink.h  |  2 +-
 fs/ksmbd/ntlmssp.h        |  6 ++--
 fs/ksmbd/smb2pdu.h        | 62 +++++++++++++++++++--------------------
 fs/ksmbd/smb_common.h     | 20 ++++++-------
 fs/ksmbd/transport_rdma.c |  2 +-
 fs/ksmbd/xattr.h          |  2 +-
 6 files changed, 47 insertions(+), 47 deletions(-)

Comments

kernel test robot Nov. 4, 2021, 12:56 p.m. UTC | #1
Hi Guo,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.15 next-20211104]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Guo-Zhengkui/ksmbd-fix-flexible_array-cocci-warnings/20211104-125818
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git ce840177930f591a181f55515fc6ac9e1f56b84a
config: i386-randconfig-a014-20211104 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 847a6807332b13f43704327c2d30103ec0347c77)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/108b059c31aa204258aec14b2ad696fbee08aeb9
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Guo-Zhengkui/ksmbd-fix-flexible_array-cocci-warnings/20211104-125818
        git checkout 108b059c31aa204258aec14b2ad696fbee08aeb9
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> fs/ksmbd/smb2pdu.c:284:35: error: invalid application of 'sizeof' to an incomplete type '__u8[]'
                   sizeof(struct smb2_hdr) - sizeof(rsp->Buffer) +
                                                   ^~~~~~~~~~~~~
   fs/ksmbd/smb2pdu.c:1190:36: error: invalid application of 'sizeof' to an incomplete type '__u8[]'
                           sizeof(struct smb2_hdr) - sizeof(rsp->Buffer) +
                                                           ^~~~~~~~~~~~~
>> fs/ksmbd/smb2pdu.c:4183:32: error: arithmetic on a pointer to an incomplete type 'char[]'
                   ptr = (char *)(&eainfo->name + name_len + 1);
                                  ~~~~~~~~~~~~~ ^
   3 errors generated.


vim +284 fs/ksmbd/smb2pdu.c

e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  223  
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  224  /**
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  225   * init_smb2_neg_rsp() - initialize smb2 response for negotiate command
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  226   * @work:	smb work containing smb request buffer
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  227   *
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  228   * smb2 negotiate response is sent in reply of smb1 negotiate command for
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  229   * dialect auto-negotiation.
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  230   */
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  231  int init_smb2_neg_rsp(struct ksmbd_work *work)
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  232  {
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  233  	struct smb2_hdr *rsp_hdr;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  234  	struct smb2_negotiate_rsp *rsp;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  235  	struct ksmbd_conn *conn = work->conn;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  236  
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  237  	if (conn->need_neg == false)
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  238  		return -EINVAL;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  239  
e5066499079de0 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-30  240  	rsp_hdr = work->response_buf;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  241  
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  242  	memset(rsp_hdr, 0, sizeof(struct smb2_hdr) + 2);
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  243  
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  244  	rsp_hdr->smb2_buf_length =
d8fb29980cb536 fs/ksmbd/smb2pdu.c Hyunchul Lee 2021-06-25  245  		cpu_to_be32(smb2_hdr_size_no_buflen(conn->vals));
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  246  
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  247  	rsp_hdr->ProtocolId = SMB2_PROTO_NUMBER;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  248  	rsp_hdr->StructureSize = SMB2_HEADER_STRUCTURE_SIZE;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  249  	rsp_hdr->CreditRequest = cpu_to_le16(2);
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  250  	rsp_hdr->Command = SMB2_NEGOTIATE;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  251  	rsp_hdr->Flags = (SMB2_FLAGS_SERVER_TO_REDIR);
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  252  	rsp_hdr->NextCommand = 0;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  253  	rsp_hdr->MessageId = 0;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  254  	rsp_hdr->Id.SyncId.ProcessId = 0;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  255  	rsp_hdr->Id.SyncId.TreeId = 0;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  256  	rsp_hdr->SessionId = 0;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  257  	memset(rsp_hdr->Signature, 0, 16);
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  258  
e5066499079de0 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-30  259  	rsp = work->response_buf;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  260  
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  261  	WARN_ON(ksmbd_conn_good(work));
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  262  
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  263  	rsp->StructureSize = cpu_to_le16(65);
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  264  	ksmbd_debug(SMB, "conn->dialect 0x%x\n", conn->dialect);
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  265  	rsp->DialectRevision = cpu_to_le16(conn->dialect);
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  266  	/* Not setting conn guid rsp->ServerGUID, as it
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  267  	 * not used by client for identifying connection
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  268  	 */
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  269  	rsp->Capabilities = cpu_to_le32(conn->vals->capabilities);
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  270  	/* Default Max Message Size till SMB2.0, 64K*/
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  271  	rsp->MaxTransactSize = cpu_to_le32(conn->vals->max_trans_size);
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  272  	rsp->MaxReadSize = cpu_to_le32(conn->vals->max_read_size);
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  273  	rsp->MaxWriteSize = cpu_to_le32(conn->vals->max_write_size);
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  274  
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  275  	rsp->SystemTime = cpu_to_le64(ksmbd_systime());
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  276  	rsp->ServerStartTime = 0;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  277  
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  278  	rsp->SecurityBufferOffset = cpu_to_le16(128);
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  279  	rsp->SecurityBufferLength = cpu_to_le16(AUTH_GSS_LENGTH);
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  280  	ksmbd_copy_gss_neg_header(((char *)(&rsp->hdr) +
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  281  		sizeof(rsp->hdr.smb2_buf_length)) +
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  282  		le16_to_cpu(rsp->SecurityBufferOffset));
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  283  	inc_rfc1001_len(rsp, sizeof(struct smb2_negotiate_rsp) -
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16 @284  		sizeof(struct smb2_hdr) - sizeof(rsp->Buffer) +
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  285  		AUTH_GSS_LENGTH);
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  286  	rsp->SecurityMode = SMB2_NEGOTIATE_SIGNING_ENABLED_LE;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  287  	if (server_conf.signing == KSMBD_CONFIG_OPT_MANDATORY)
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  288  		rsp->SecurityMode |= SMB2_NEGOTIATE_SIGNING_REQUIRED_LE;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  289  	conn->use_spnego = true;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  290  
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  291  	ksmbd_conn_set_need_negotiate(work);
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  292  	return 0;
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  293  }
e2f34481b24db2 fs/cifsd/smb2pdu.c Namjae Jeon  2021-03-16  294  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/fs/ksmbd/ksmbd_netlink.h b/fs/ksmbd/ksmbd_netlink.h
index c6718a05d347..71d018c2e016 100644
--- a/fs/ksmbd/ksmbd_netlink.h
+++ b/fs/ksmbd/ksmbd_netlink.h
@@ -231,7 +231,7 @@  struct ksmbd_rpc_command {
 struct ksmbd_spnego_authen_request {
 	__u32	handle;
 	__u16	spnego_blob_len;	/* the length of spnego_blob */
-	__u8	spnego_blob[0];		/*
+	__u8	spnego_blob[];		/*
 					 * the GSS token from SecurityBuffer of
 					 * SMB2 SESSION SETUP request
 					 */
diff --git a/fs/ksmbd/ntlmssp.h b/fs/ksmbd/ntlmssp.h
index adaf4c0cbe8f..f13153c18b4e 100644
--- a/fs/ksmbd/ntlmssp.h
+++ b/fs/ksmbd/ntlmssp.h
@@ -95,7 +95,7 @@  struct security_buffer {
 struct target_info {
 	__le16 Type;
 	__le16 Length;
-	__u8 Content[0];
+	__u8 Content[];
 } __packed;
 
 struct negotiate_message {
@@ -108,7 +108,7 @@  struct negotiate_message {
 	 * struct security_buffer for version info not present since we
 	 * do not set the version is present flag
 	 */
-	char DomainString[0];
+	char DomainString[];
 	/* followed by WorkstationString */
 } __packed;
 
@@ -140,7 +140,7 @@  struct authenticate_message {
 	 * struct security_buffer for version info not present since we
 	 * do not set the version is present flag
 	 */
-	char UserString[0];
+	char UserString[];
 } __packed;
 
 struct ntlmv2_resp {
diff --git a/fs/ksmbd/smb2pdu.h b/fs/ksmbd/smb2pdu.h
index ff5a2f01d34a..b415a4b914a4 100644
--- a/fs/ksmbd/smb2pdu.h
+++ b/fs/ksmbd/smb2pdu.h
@@ -206,7 +206,7 @@  struct smb2_err_rsp {
 	__u8   ErrorContextCount;
 	__u8   Reserved;
 	__le32 ByteCount;  /* even if zero, at least one byte follows */
-	__u8   ErrorData[1];  /* variable length */
+	__u8   ErrorData[];  /* variable length */
 } __packed;
 
 struct smb2_negotiate_req {
@@ -221,7 +221,7 @@  struct smb2_negotiate_req {
 	__le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */
 	__le16 NegotiateContextCount;  /* SMB3.1.1 only. MBZ earlier */
 	__le16 Reserved2;
-	__le16 Dialects[1]; /* One dialect (vers=) at a time for now */
+	__le16 Dialects[]; /* One dialect (vers=) at a time for now */
 } __packed;
 
 /* SecurityMode flags */
@@ -364,7 +364,7 @@  struct smb2_negotiate_rsp {
 	__le16 SecurityBufferOffset;
 	__le16 SecurityBufferLength;
 	__le32 NegotiateContextOffset;	/* Pre:SMB3.1.1 was reserved/ignored */
-	__u8   Buffer[1];	/* variable length GSS security buffer */
+	__u8   Buffer[];	/* variable length GSS security buffer */
 } __packed;
 
 /* Flags */
@@ -389,7 +389,7 @@  struct smb2_sess_setup_req {
 	__le16 SecurityBufferOffset;
 	__le16 SecurityBufferLength;
 	__le64 PreviousSessionId;
-	__u8   Buffer[1];	/* variable length GSS security buffer */
+	__u8   Buffer[];	/* variable length GSS security buffer */
 } __packed;
 
 /* Flags/Reserved for SMB3.1.1 */
@@ -405,7 +405,7 @@  struct smb2_sess_setup_rsp {
 	__le16 SessionFlags;
 	__le16 SecurityBufferOffset;
 	__le16 SecurityBufferLength;
-	__u8   Buffer[1];	/* variable length GSS security buffer */
+	__u8   Buffer[];	/* variable length GSS security buffer */
 } __packed;
 
 struct smb2_logoff_req {
@@ -426,7 +426,7 @@  struct smb2_tree_connect_req {
 	__le16 Reserved;	/* Flags in SMB3.1.1 */
 	__le16 PathOffset;
 	__le16 PathLength;
-	__u8   Buffer[1];	/* variable length */
+	__u8   Buffer[];	/* variable length */
 } __packed;
 
 struct smb2_tree_connect_rsp {
@@ -594,7 +594,7 @@  struct smb2_create_req {
 	__le16 NameLength;
 	__le32 CreateContextsOffset;
 	__le32 CreateContextsLength;
-	__u8   Buffer[0];
+	__u8   Buffer[];
 } __packed;
 
 struct smb2_create_rsp {
@@ -615,7 +615,7 @@  struct smb2_create_rsp {
 	__le64  VolatileFileId;
 	__le32 CreateContextsOffset;
 	__le32 CreateContextsLength;
-	__u8   Buffer[1];
+	__u8   Buffer[];
 } __packed;
 
 struct create_context {
@@ -625,7 +625,7 @@  struct create_context {
 	__le16 Reserved;
 	__le16 DataOffset;
 	__le32 DataLength;
-	__u8 Buffer[0];
+	__u8 Buffer[];
 } __packed;
 
 struct create_durable_req_v2 {
@@ -840,7 +840,7 @@  struct smb2_read_req {
 	__le32 RemainingBytes;
 	__le16 ReadChannelInfoOffset; /* Reserved MBZ */
 	__le16 ReadChannelInfoLength; /* Reserved MBZ */
-	__u8   Buffer[1];
+	__u8   Buffer[];
 } __packed;
 
 struct smb2_read_rsp {
@@ -851,7 +851,7 @@  struct smb2_read_rsp {
 	__le32 DataLength;
 	__le32 DataRemaining;
 	__u32  Reserved2;
-	__u8   Buffer[1];
+	__u8   Buffer[];
 } __packed;
 
 /* For write request Flags field below the following flag is defined: */
@@ -870,7 +870,7 @@  struct smb2_write_req {
 	__le16 WriteChannelInfoOffset; /* Reserved MBZ */
 	__le16 WriteChannelInfoLength; /* Reserved MBZ */
 	__le32 Flags;
-	__u8   Buffer[1];
+	__u8   Buffer[];
 } __packed;
 
 struct smb2_write_rsp {
@@ -881,7 +881,7 @@  struct smb2_write_rsp {
 	__le32 DataLength;
 	__le32 DataRemaining;
 	__u32  Reserved2;
-	__u8   Buffer[1];
+	__u8   Buffer[];
 } __packed;
 
 #define SMB2_0_IOCTL_IS_FSCTL 0x00000001
@@ -909,7 +909,7 @@  struct smb2_ioctl_req {
 	__le32 MaxOutputResponse;
 	__le32 Flags;
 	__le32 Reserved2;
-	__u8   Buffer[1];
+	__u8   Buffer[];
 } __packed;
 
 struct smb2_ioctl_rsp {
@@ -925,7 +925,7 @@  struct smb2_ioctl_rsp {
 	__le32 OutputCount;
 	__le32 Flags;
 	__le32 Reserved2;
-	__u8   Buffer[1];
+	__u8   Buffer[];
 } __packed;
 
 struct validate_negotiate_info_req {
@@ -933,7 +933,7 @@  struct validate_negotiate_info_req {
 	__u8   Guid[SMB2_CLIENT_GUID_SIZE];
 	__le16 SecurityMode;
 	__le16 DialectCount;
-	__le16 Dialects[1]; /* dialect (someday maybe list) client asked for */
+	__le16 Dialects[]; /* dialect (someday maybe list) client asked for */
 } __packed;
 
 struct validate_negotiate_info_rsp {
@@ -996,7 +996,7 @@  struct copychunk_ioctl_req {
 	__le64 ResumeKey[3];
 	__le32 ChunkCount;
 	__le32 Reserved;
-	__u8 Chunks[1]; /* array of srv_copychunk */
+	__u8 Chunks[]; /* array of srv_copychunk */
 } __packed;
 
 struct srv_copychunk {
@@ -1067,7 +1067,7 @@  struct smb2_notify_rsp {
 	__le16 StructureSize; /* Must be 9 */
 	__le16 OutputBufferOffset;
 	__le32 OutputBufferLength;
-	__u8 Buffer[1];
+	__u8 Buffer[];
 } __packed;
 
 /* SMB2 Notify Action Flags */
@@ -1102,7 +1102,7 @@  struct smb2_lock_req {
 	__le64  PersistentFileId;
 	__le64  VolatileFileId;
 	/* Followed by at least one */
-	struct smb2_lock_element locks[1];
+	struct smb2_lock_element locks[];
 } __packed;
 
 struct smb2_lock_rsp {
@@ -1140,7 +1140,7 @@  struct smb2_query_directory_req {
 	__le16 FileNameOffset;
 	__le16 FileNameLength;
 	__le32 OutputBufferLength;
-	__u8   Buffer[1];
+	__u8   Buffer[];
 } __packed;
 
 struct smb2_query_directory_rsp {
@@ -1148,7 +1148,7 @@  struct smb2_query_directory_rsp {
 	__le16 StructureSize; /* Must be 9 */
 	__le16 OutputBufferOffset;
 	__le32 OutputBufferLength;
-	__u8   Buffer[1];
+	__u8   Buffer[];
 } __packed;
 
 /* Possible InfoType values */
@@ -1184,7 +1184,7 @@  struct smb2_query_info_req {
 	__le32 Flags;
 	__le64  PersistentFileId;
 	__le64  VolatileFileId;
-	__u8   Buffer[1];
+	__u8   Buffer[];
 } __packed;
 
 struct smb2_query_info_rsp {
@@ -1192,7 +1192,7 @@  struct smb2_query_info_rsp {
 	__le16 StructureSize; /* Must be 9 */
 	__le16 OutputBufferOffset;
 	__le32 OutputBufferLength;
-	__u8   Buffer[1];
+	__u8   Buffer[];
 } __packed;
 
 struct smb2_set_info_req {
@@ -1206,7 +1206,7 @@  struct smb2_set_info_req {
 	__le32 AdditionalInformation;
 	__le64  PersistentFileId;
 	__le64  VolatileFileId;
-	__u8   Buffer[1];
+	__u8   Buffer[];
 } __packed;
 
 struct smb2_set_info_rsp {
@@ -1426,7 +1426,7 @@  struct smb2_file_rename_info { /* encoding of request for level 10 */
 	__u8   Reserved[7];
 	__u64  RootDirectory;  /* MBZ for network operations (why says spec?) */
 	__le32 FileNameLength;
-	char   FileName[0];     /* New name to be assigned */
+	char   FileName[];     /* New name to be assigned */
 } __packed; /* level 10 Set */
 
 struct smb2_file_link_info { /* encoding of request for level 11 */
@@ -1435,7 +1435,7 @@  struct smb2_file_link_info { /* encoding of request for level 11 */
 	__u8   Reserved[7];
 	__u64  RootDirectory;  /* MBZ for network operations (why says spec?) */
 	__le32 FileNameLength;
-	char   FileName[0];     /* Name to be assigned to new link */
+	char   FileName[];     /* Name to be assigned to new link */
 } __packed; /* level 11 Set */
 
 /*
@@ -1463,7 +1463,7 @@  struct smb2_file_all_info { /* data block encoding of response to level 18 */
 	__le32 Mode;
 	__le32 AlignmentRequirement;
 	__le32 FileNameLength;
-	char   FileName[1];
+	char   FileName[];
 } __packed; /* level 18 Query */
 
 struct smb2_file_basic_info { /* data block encoding of response to level 18 */
@@ -1477,7 +1477,7 @@  struct smb2_file_basic_info { /* data block encoding of response to level 18 */
 
 struct smb2_file_alt_name_info {
 	__le32 FileNameLength;
-	char FileName[0];
+	char FileName[];
 } __packed;
 
 struct smb2_file_stream_info {
@@ -1485,7 +1485,7 @@  struct smb2_file_stream_info {
 	__le32  StreamNameLength;
 	__le64 StreamSize;
 	__le64 StreamAllocationSize;
-	char   StreamName[0];
+	char   StreamName[];
 } __packed;
 
 struct smb2_file_eof_info { /* encoding of request for level 10 */
@@ -1566,7 +1566,7 @@  struct smb2_ea_info {
 	__u8   Flags;
 	__u8   EaNameLength;
 	__le16 EaValueLength;
-	char name[1];
+	char name[];
 	/* optionally followed by value */
 } __packed; /* level 15 Query */
 
@@ -1629,7 +1629,7 @@  struct smb2_posix_info {
 	__le32 Mode;
 	u8 SidBuffer[40];
 	__le32 name_len;
-	u8 name[1];
+	u8 name[];
 	/*
 	 * var sized owner SID
 	 * var sized group SID
diff --git a/fs/ksmbd/smb_common.h b/fs/ksmbd/smb_common.h
index 6e79e7577f6b..619fad7dd887 100644
--- a/fs/ksmbd/smb_common.h
+++ b/fs/ksmbd/smb_common.h
@@ -240,7 +240,7 @@  struct smb_hdr {
 struct smb_negotiate_req {
 	struct smb_hdr hdr;     /* wct = 0 */
 	__le16 ByteCount;
-	unsigned char DialectsArray[1];
+	unsigned char DialectsArray[];
 } __packed;
 
 struct smb_negotiate_rsp {
@@ -265,7 +265,7 @@  struct smb_negotiate_rsp {
 		/* then security blob if cap_extended_security negotiated */
 		struct {
 			unsigned char GUID[SMB1_CLIENT_GUID_SIZE];
-			unsigned char SecurityBlob[1];
+			unsigned char SecurityBlob[];
 		} __packed extended_response;
 	} __packed u;
 } __packed;
@@ -274,7 +274,7 @@  struct filesystem_attribute_info {
 	__le32 Attributes;
 	__le32 MaxPathNameComponentLength;
 	__le32 FileSystemNameLen;
-	__le16 FileSystemName[1]; /* do not have to save this - get subset? */
+	__le16 FileSystemName[]; /* do not have to save this - get subset? */
 } __packed;
 
 struct filesystem_device_info {
@@ -287,7 +287,7 @@  struct filesystem_vol_info {
 	__le32 SerialNumber;
 	__le32 VolumeLabelSize;
 	__le16 Reserved;
-	__le16 VolumeLabel[1];
+	__le16 VolumeLabel[];
 } __packed;
 
 struct filesystem_info {
@@ -324,14 +324,14 @@  struct file_directory_info {
 	__le64 AllocationSize;
 	__le32 ExtFileAttributes;
 	__le32 FileNameLength;
-	char FileName[1];
+	char FileName[];
 } __packed;   /* level 0x101 FF resp data */
 
 struct file_names_info {
 	__le32 NextEntryOffset;
 	__u32 FileIndex;
 	__le32 FileNameLength;
-	char FileName[1];
+	char FileName[];
 } __packed;   /* level 0xc FF resp data */
 
 struct file_full_directory_info {
@@ -346,7 +346,7 @@  struct file_full_directory_info {
 	__le32 ExtFileAttributes;
 	__le32 FileNameLength;
 	__le32 EaSize;
-	char FileName[1];
+	char FileName[];
 } __packed; /* level 0x102 FF resp */
 
 struct file_both_directory_info {
@@ -364,7 +364,7 @@  struct file_both_directory_info {
 	__u8   ShortNameLength;
 	__u8   Reserved;
 	__u8   ShortName[24];
-	char FileName[1];
+	char FileName[];
 } __packed; /* level 0x104 FFrsp data */
 
 struct file_id_both_directory_info {
@@ -384,7 +384,7 @@  struct file_id_both_directory_info {
 	__u8   ShortName[24];
 	__le16 Reserved2;
 	__le64 UniqueId;
-	char FileName[1];
+	char FileName[];
 } __packed;
 
 struct file_id_full_dir_info {
@@ -401,7 +401,7 @@  struct file_id_full_dir_info {
 	__le32 EaSize; /* EA size */
 	__le32 Reserved;
 	__le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
-	char FileName[1];
+	char FileName[];
 } __packed; /* level 0x105 FF rsp data */
 
 struct smb_version_values {
diff --git a/fs/ksmbd/transport_rdma.c b/fs/ksmbd/transport_rdma.c
index 6330dfc302ff..ca62060acd2b 100644
--- a/fs/ksmbd/transport_rdma.c
+++ b/fs/ksmbd/transport_rdma.c
@@ -198,7 +198,7 @@  struct smb_direct_rdma_rw_msg {
 	struct completion	*completion;
 	struct rdma_rw_ctx	rw_ctx;
 	struct sg_table		sgt;
-	struct scatterlist	sg_list[0];
+	struct scatterlist	sg_list[];
 };
 
 static inline int get_buf_page_count(void *buf, int size)
diff --git a/fs/ksmbd/xattr.h b/fs/ksmbd/xattr.h
index 8857c01093d9..16499ca5c82d 100644
--- a/fs/ksmbd/xattr.h
+++ b/fs/ksmbd/xattr.h
@@ -76,7 +76,7 @@  struct xattr_acl_entry {
 struct xattr_smb_acl {
 	int count;
 	int next;
-	struct xattr_acl_entry entries[0];
+	struct xattr_acl_entry entries[];
 };
 
 /* 64bytes hash in xattr_ntacl is computed with sha256 */