CC: [email protected]
In-Reply-To: <[email protected]>
References: <[email protected]>
TO: Baokun Li <[email protected]>

Hi Baokun,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on next-20210617]

url:    
https://github.com/0day-ci/linux/commits/Baokun-Li/cifs-convert-list_for_each-to-entry-variant-in-smb2misc-c/20210618-115515
base:    7d9c6b8147bdd76d7eb2cf6f74f84c6918ae0939
:::::: branch date: 3 hours ago
:::::: commit date: 3 hours ago
config: x86_64-randconfig-c022-20210618 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
Reported-by: Julia Lawall <[email protected]>


cocci warnings: (new ones prefixed by >>)
>> fs/cifs/smb2misc.c:170:2-21: iterator with update on line 174

vim +170 fs/cifs/smb2misc.c

136ff1b4b65edf Steve French    2018-04-08  147  
093b2bdad3221e Pavel Shilovsky 2011-06-08  148  int
98170fb53587a4 Ronnie Sahlberg 2018-05-31  149  smb2_check_message(char *buf, 
unsigned int len, struct TCP_Server_Info *srvr)
093b2bdad3221e Pavel Shilovsky 2011-06-08  150  {
1fc6ad2f10ad6f Ronnie Sahlberg 2018-06-01  151          struct smb2_sync_hdr 
*shdr = (struct smb2_sync_hdr *)buf;
98170fb53587a4 Ronnie Sahlberg 2018-05-31  152          struct smb2_sync_pdu 
*pdu = (struct smb2_sync_pdu *)shdr;
373512ec5c105e Steve French    2015-12-18  153          __u64 mid;
093b2bdad3221e Pavel Shilovsky 2011-06-08  154          __u32 clc_len;  /* 
calculated length */
093b2bdad3221e Pavel Shilovsky 2011-06-08  155          int command;
98170fb53587a4 Ronnie Sahlberg 2018-05-31  156          int pdu_size = 
sizeof(struct smb2_sync_pdu);
98170fb53587a4 Ronnie Sahlberg 2018-05-31  157          int hdr_size = 
sizeof(struct smb2_sync_hdr);
093b2bdad3221e Pavel Shilovsky 2011-06-08  158  
093b2bdad3221e Pavel Shilovsky 2011-06-08  159          /*
093b2bdad3221e Pavel Shilovsky 2011-06-08  160           * Add function to do 
table lookup of StructureSize by command
093b2bdad3221e Pavel Shilovsky 2011-06-08  161           * ie Validate the wct 
via smb2_struct_sizes table above
093b2bdad3221e Pavel Shilovsky 2011-06-08  162           */
31473fc4f9653b Pavel Shilovsky 2016-10-24  163          if (shdr->ProtocolId == 
SMB2_TRANSFORM_PROTO_NUM) {
373512ec5c105e Steve French    2015-12-18  164                  struct 
smb2_transform_hdr *thdr =
373512ec5c105e Steve French    2015-12-18  165                          (struct 
smb2_transform_hdr *)buf;
373512ec5c105e Steve French    2015-12-18  166                  struct cifs_ses 
*ses = NULL;
373512ec5c105e Steve French    2015-12-18  167  
373512ec5c105e Steve French    2015-12-18  168                  /* decrypt 
frame now that it is completely read in */
373512ec5c105e Steve French    2015-12-18  169                  
spin_lock(&cifs_tcp_ses_lock);
dc85102637272c Baokun Li       2021-06-18 @170                  
list_for_each_entry(ses, &srvr->smb_ses_list, smb_ses_list) {
373512ec5c105e Steve French    2015-12-18  171                          if 
(ses->Suid == thdr->SessionId)
373512ec5c105e Steve French    2015-12-18  172                                  
break;
373512ec5c105e Steve French    2015-12-18  173  
373512ec5c105e Steve French    2015-12-18 @174                          ses = 
NULL;
373512ec5c105e Steve French    2015-12-18  175                  }
373512ec5c105e Steve French    2015-12-18  176                  
spin_unlock(&cifs_tcp_ses_lock);
373512ec5c105e Steve French    2015-12-18  177                  if (ses == 
NULL) {
373512ec5c105e Steve French    2015-12-18  178                          
cifs_dbg(VFS, "no decryption - session id not found\n");
373512ec5c105e Steve French    2015-12-18  179                          return 
1;
373512ec5c105e Steve French    2015-12-18  180                  }
373512ec5c105e Steve French    2015-12-18  181          }
373512ec5c105e Steve French    2015-12-18  182  
31473fc4f9653b Pavel Shilovsky 2016-10-24  183          mid = 
le64_to_cpu(shdr->MessageId);
98170fb53587a4 Ronnie Sahlberg 2018-05-31  184          if (len < pdu_size) {
98170fb53587a4 Ronnie Sahlberg 2018-05-31  185                  if ((len >= 
hdr_size)
31473fc4f9653b Pavel Shilovsky 2016-10-24  186                      && 
(shdr->Status != 0)) {
093b2bdad3221e Pavel Shilovsky 2011-06-08  187                          
pdu->StructureSize2 = 0;
093b2bdad3221e Pavel Shilovsky 2011-06-08  188                          /*
093b2bdad3221e Pavel Shilovsky 2011-06-08  189                           * As 
with SMB/CIFS, on some error cases servers may
093b2bdad3221e Pavel Shilovsky 2011-06-08  190                           * not 
return wct properly
093b2bdad3221e Pavel Shilovsky 2011-06-08  191                           */
093b2bdad3221e Pavel Shilovsky 2011-06-08  192                          return 
0;
093b2bdad3221e Pavel Shilovsky 2011-06-08  193                  } else {
f96637be081141 Joe Perches     2013-05-04  194                          
cifs_dbg(VFS, "Length less than SMB header size\n");
093b2bdad3221e Pavel Shilovsky 2011-06-08  195                  }
093b2bdad3221e Pavel Shilovsky 2011-06-08  196                  return 1;
093b2bdad3221e Pavel Shilovsky 2011-06-08  197          }
1fc6ad2f10ad6f Ronnie Sahlberg 2018-06-01  198          if (len > 
CIFSMaxBufSize + MAX_SMB2_HDR_SIZE) {
f96637be081141 Joe Perches     2013-05-04  199                  cifs_dbg(VFS, 
"SMB length greater than maximum, mid=%llu\n",
f96637be081141 Joe Perches     2013-05-04  200                           mid);
093b2bdad3221e Pavel Shilovsky 2011-06-08  201                  return 1;
093b2bdad3221e Pavel Shilovsky 2011-06-08  202          }
093b2bdad3221e Pavel Shilovsky 2011-06-08  203  
31473fc4f9653b Pavel Shilovsky 2016-10-24  204          if 
(check_smb2_hdr(shdr, mid))
093b2bdad3221e Pavel Shilovsky 2011-06-08  205                  return 1;
093b2bdad3221e Pavel Shilovsky 2011-06-08  206  
31473fc4f9653b Pavel Shilovsky 2016-10-24  207          if (shdr->StructureSize 
!= SMB2_HEADER_STRUCTURE_SIZE) {
a0a3036b81f1f6 Joe Perches     2020-04-14  208                  cifs_dbg(VFS, 
"Invalid structure size %u\n",
31473fc4f9653b Pavel Shilovsky 2016-10-24  209                           
le16_to_cpu(shdr->StructureSize));
093b2bdad3221e Pavel Shilovsky 2011-06-08  210                  return 1;
093b2bdad3221e Pavel Shilovsky 2011-06-08  211          }
093b2bdad3221e Pavel Shilovsky 2011-06-08  212  
31473fc4f9653b Pavel Shilovsky 2016-10-24  213          command = 
le16_to_cpu(shdr->Command);
093b2bdad3221e Pavel Shilovsky 2011-06-08  214          if (command >= 
NUMBER_OF_SMB2_COMMANDS) {
a0a3036b81f1f6 Joe Perches     2020-04-14  215                  cifs_dbg(VFS, 
"Invalid SMB2 command %d\n", command);
093b2bdad3221e Pavel Shilovsky 2011-06-08  216                  return 1;
093b2bdad3221e Pavel Shilovsky 2011-06-08  217          }
093b2bdad3221e Pavel Shilovsky 2011-06-08  218  
093b2bdad3221e Pavel Shilovsky 2011-06-08  219          if 
(smb2_rsp_struct_sizes[command] != pdu->StructureSize2) {
31473fc4f9653b Pavel Shilovsky 2016-10-24  220                  if (command != 
SMB2_OPLOCK_BREAK_HE && (shdr->Status == 0 ||
983c88a497914d Pavel Shilovsky 2012-09-18  221                      
pdu->StructureSize2 != SMB2_ERROR_STRUCTURE_SIZE2)) {
093b2bdad3221e Pavel Shilovsky 2011-06-08  222                          /* 
error packets have 9 byte structure size */
a0a3036b81f1f6 Joe Perches     2020-04-14  223                          
cifs_dbg(VFS, "Invalid response size %u for command %d\n",
093b2bdad3221e Pavel Shilovsky 2011-06-08  224                                  
 le16_to_cpu(pdu->StructureSize2), command);
093b2bdad3221e Pavel Shilovsky 2011-06-08  225                          return 
1;
31473fc4f9653b Pavel Shilovsky 2016-10-24  226                  } else if 
(command == SMB2_OPLOCK_BREAK_HE
31473fc4f9653b Pavel Shilovsky 2016-10-24  227                             && 
(shdr->Status == 0)
0822f51426b51b Pavel Shilovsky 2012-09-19  228                             && 
(le16_to_cpu(pdu->StructureSize2) != 44)
0822f51426b51b Pavel Shilovsky 2012-09-19  229                             && 
(le16_to_cpu(pdu->StructureSize2) != 36)) {
0822f51426b51b Pavel Shilovsky 2012-09-19  230                          /* 
special case for SMB2.1 lease break message */
a0a3036b81f1f6 Joe Perches     2020-04-14  231                          
cifs_dbg(VFS, "Invalid response size %d for oplock break\n",
0822f51426b51b Pavel Shilovsky 2012-09-19  232                                  
 le16_to_cpu(pdu->StructureSize2));
0822f51426b51b Pavel Shilovsky 2012-09-19  233                          return 
1;
093b2bdad3221e Pavel Shilovsky 2011-06-08  234                  }
093b2bdad3221e Pavel Shilovsky 2011-06-08  235          }
093b2bdad3221e Pavel Shilovsky 2011-06-08  236  
98170fb53587a4 Ronnie Sahlberg 2018-05-31  237          clc_len = 
smb2_calc_size(buf, srvr);
093b2bdad3221e Pavel Shilovsky 2011-06-08  238  
136ff1b4b65edf Steve French    2018-04-08  239          if (shdr->Command == 
SMB2_NEGOTIATE)
1fc6ad2f10ad6f Ronnie Sahlberg 2018-06-01  240                  clc_len += 
get_neg_ctxt_len(shdr, len, clc_len);
0fdfef9aa7ee68 Steve French    2018-06-28  241  
98170fb53587a4 Ronnie Sahlberg 2018-05-31  242          if (len != clc_len) {
98170fb53587a4 Ronnie Sahlberg 2018-05-31  243                  cifs_dbg(FYI, 
"Calculated size %u length %u mismatch mid %llu\n",
98170fb53587a4 Ronnie Sahlberg 2018-05-31  244                           
clc_len, len, mid);
b42bf88828cde6 Pavel Shilovsky 2013-08-14  245                  /* create 
failed on symlink */
b42bf88828cde6 Pavel Shilovsky 2013-08-14  246                  if (command == 
SMB2_CREATE_HE &&
31473fc4f9653b Pavel Shilovsky 2016-10-24  247                      
shdr->Status == STATUS_STOPPED_ON_SYMLINK)
b42bf88828cde6 Pavel Shilovsky 2013-08-14  248                          return 
0;
983c88a497914d Pavel Shilovsky 2012-09-18  249                  /* Windows 7 
server returns 24 bytes more */
98170fb53587a4 Ronnie Sahlberg 2018-05-31  250                  if (clc_len + 
24 == len && command == SMB2_OPLOCK_BREAK_HE)
983c88a497914d Pavel Shilovsky 2012-09-18  251                          return 
0;
754789a1c04610 Steve French    2014-08-15  252                  /* server can 
return one byte more due to implied bcc[0] */
98170fb53587a4 Ronnie Sahlberg 2018-05-31  253                  if (clc_len == 
len + 1)
7411286088d5ba Pavel Shilovsky 2012-07-27  254                          return 
0;
754789a1c04610 Steve French    2014-08-15  255  
e6c47dd0da1e3a Ronnie Sahlberg 2018-08-22  256                  /*
e6c47dd0da1e3a Ronnie Sahlberg 2018-08-22  257                   * Some windows 
servers (win2016) will pad also the final
e6c47dd0da1e3a Ronnie Sahlberg 2018-08-22  258                   * PDU in a 
compound to 8 bytes.
e6c47dd0da1e3a Ronnie Sahlberg 2018-08-22  259                   */
e6c47dd0da1e3a Ronnie Sahlberg 2018-08-22  260                  if (((clc_len + 
7) & ~7) == len)
e6c47dd0da1e3a Ronnie Sahlberg 2018-08-22  261                          return 
0;
e6c47dd0da1e3a Ronnie Sahlberg 2018-08-22  262  
754789a1c04610 Steve French    2014-08-15  263                  /*
754789a1c04610 Steve French    2014-08-15  264                   * MacOS server 
pads after SMB2.1 write response with 3 bytes
754789a1c04610 Steve French    2014-08-15  265                   * of junk. 
Other servers match RFC1001 len to actual
754789a1c04610 Steve French    2014-08-15  266                   * SMB2/SMB3 
frame length (header + smb2 response specific data)
25f2573512d7b3 Steve French    2018-08-29  267                   * Some windows 
servers also pad up to 8 bytes when compounding.
754789a1c04610 Steve French    2014-08-15  268                   */
037d050724ed30 Steve French    2019-11-08  269                  if (clc_len < 
len)
754789a1c04610 Steve French    2014-08-15  270                          return 
0;
037d050724ed30 Steve French    2019-11-08  271  
25f2573512d7b3 Steve French    2018-08-29  272                  pr_warn_once(
25f2573512d7b3 Steve French    2018-08-29  273                          "srv 
rsp too short, len %d not %d. cmd:%d mid:%llu\n",
25f2573512d7b3 Steve French    2018-08-29  274                          len, 
clc_len, command, mid);
754789a1c04610 Steve French    2014-08-15  275  
093b2bdad3221e Pavel Shilovsky 2011-06-08  276                  return 1;
093b2bdad3221e Pavel Shilovsky 2011-06-08  277          }
093b2bdad3221e Pavel Shilovsky 2011-06-08  278          return 0;
093b2bdad3221e Pavel Shilovsky 2011-06-08  279  }
093b2bdad3221e Pavel Shilovsky 2011-06-08  280  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to