Re: [PATCH] ksmbd: fix flexible_array.cocci warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>

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@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip


[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux