All of lore.kernel.org
 help / color / mirror / Atom feed
* [smfrench-smb3:for-next 14/18] fs/cifs/smb2pdu.c:341:2: warning: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn]
@ 2021-11-21  6:53 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2021-11-21  6:53 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 29309 bytes --]

CC: kbuild-all(a)lists.01.org
TO: Steve French <stfrench@microsoft.com>

tree:   git://github.com/smfrench/smb3-kernel.git for-next
head:   28711a66701e3aefc5748dcde38dba1e2e79de34
commit: a6649da5f02a578a9a4b1fccf3402cc9cf378ede [14/18] cifs: avoid race during socket reconnect between send  and recv
:::::: branch date: 34 hours ago
:::::: commit date: 34 hours ago
config: i386-randconfig-c001-20211118 (attached as .config)
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/smfrench/smb3-kernel/commit/a6649da5f02a578a9a4b1fccf3402cc9cf378ede
        git remote add smfrench-smb3 git://github.com/smfrench/smb3-kernel.git
        git fetch --no-tags smfrench-smb3 for-next
        git checkout a6649da5f02a578a9a4b1fccf3402cc9cf378ede
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386 clang-analyzer 

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


clang-analyzer warnings: (new ones prefixed by >>)
           ^     ~
   net/9p/client.c:1759:2: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
           err = 0;
           ^     ~
   net/9p/client.c:1759:2: note: Value stored to 'err' is never read
           err = 0;
           ^     ~
   net/9p/client.c:1913:2: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
           err = 0;
           ^     ~
   net/9p/client.c:1913:2: note: Value stored to 'err' is never read
           err = 0;
           ^     ~
   net/9p/client.c:2012:2: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
           err = 0;
           ^     ~
   net/9p/client.c:2012:2: note: Value stored to 'err' is never read
           err = 0;
           ^     ~
   net/9p/client.c:2089:2: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
           err = 0;
           ^     ~
   net/9p/client.c:2089:2: note: Value stored to 'err' is never read
           err = 0;
           ^     ~
   net/9p/client.c:2148:2: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
           err = 0;
           ^     ~
   net/9p/client.c:2148:2: note: Value stored to 'err' is never read
           err = 0;
           ^     ~
   net/9p/client.c:2179:2: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
           err = 0;
           ^     ~
   net/9p/client.c:2179:2: note: Value stored to 'err' is never read
           err = 0;
           ^     ~
   net/9p/client.c:2208:2: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
           err = 0;
           ^     ~
   net/9p/client.c:2208:2: note: Value stored to 'err' is never read
           err = 0;
           ^     ~
   net/9p/client.c:2240:2: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
           err = 0;
           ^     ~
   net/9p/client.c:2240:2: note: Value stored to 'err' is never read
           err = 0;
           ^     ~
   net/9p/client.c:2277:2: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
           err = 0;
           ^     ~
   net/9p/client.c:2277:2: note: Value stored to 'err' is never read
           err = 0;
           ^     ~
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   11 warnings generated.
   fs/cifs/smb2ops.c:4215:3: warning: Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
                   strcat(message, "R");
                   ^~~~~~
   fs/cifs/smb2ops.c:4215:3: note: Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
                   strcat(message, "R");
                   ^~~~~~
   fs/cifs/smb2ops.c:4219:3: warning: Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
                   strcat(message, "H");
                   ^~~~~~
   fs/cifs/smb2ops.c:4219:3: note: Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
                   strcat(message, "H");
                   ^~~~~~
   fs/cifs/smb2ops.c:4223:3: warning: Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
                   strcat(message, "W");
                   ^~~~~~
   fs/cifs/smb2ops.c:4223:3: note: Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
                   strcat(message, "W");
                   ^~~~~~
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   8 warnings generated.
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   fs/cifs/smb2transport.c:436:3: warning: Value stored to 'rc' is never read [clang-analyzer-deadcode.DeadStores]
                   rc = generate_key(ses, ptriplet->encryption.label,
                   ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/cifs/smb2transport.c:436:3: note: Value stored to 'rc' is never read
                   rc = generate_key(ses, ptriplet->encryption.label,
                   ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   fs/cifs/smb2misc.c:503:2: warning: Value stored to 'rc' is never read [clang-analyzer-deadcode.DeadStores]
           rc = SMB2_lease_break(0, tlink_tcon(lw->tlink), lw->lease_key,
           ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/cifs/smb2misc.c:503:2: note: Value stored to 'rc' is never read
           rc = SMB2_lease_break(0, tlink_tcon(lw->tlink), lw->lease_key,
           ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   10 warnings generated.
>> fs/cifs/smb2pdu.c:341:2: warning: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn]
           return rc;
           ^      ~~
   fs/cifs/smb2pdu.c:145:2: note: 'rc' declared without an initial value
           int rc;
           ^~~~~~
   fs/cifs/smb2pdu.c:155:6: note: Assuming 'tcon' is not equal to NULL
           if (tcon == NULL)
               ^~~~~~~~~~~~
   fs/cifs/smb2pdu.c:155:2: note: Taking false branch
           if (tcon == NULL)
           ^
   fs/cifs/smb2pdu.c:162:6: note: Assuming 'smb2_command' is not equal to SMB2_TREE_CONNECT
           if (smb2_command == SMB2_TREE_CONNECT || smb2_command == SMB2_IOCTL)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/cifs/smb2pdu.c:162:6: note: Left side of '||' is false
   fs/cifs/smb2pdu.c:162:43: note: Assuming 'smb2_command' is not equal to SMB2_IOCTL
           if (smb2_command == SMB2_TREE_CONNECT || smb2_command == SMB2_IOCTL)
                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/cifs/smb2pdu.c:162:2: note: Taking false branch
           if (smb2_command == SMB2_TREE_CONNECT || smb2_command == SMB2_IOCTL)
           ^
   fs/cifs/smb2pdu.c:166:6: note: Assuming field 'tidStatus' is not equal to CifsExiting
           if (tcon->tidStatus == CifsExiting) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/cifs/smb2pdu.c:166:2: note: Taking false branch
           if (tcon->tidStatus == CifsExiting) {
           ^
   fs/cifs/smb2pdu.c:182:7: note: Assuming field 'ses' is non-null
           if ((!tcon->ses) || (tcon->ses->status == CifsExiting) ||
                ^~~~~~~~~~
   fs/cifs/smb2pdu.c:182:6: note: Left side of '||' is false
           if ((!tcon->ses) || (tcon->ses->status == CifsExiting) ||
               ^
   fs/cifs/smb2pdu.c:182:23: note: Assuming field 'status' is not equal to CifsExiting
           if ((!tcon->ses) || (tcon->ses->status == CifsExiting) ||
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/cifs/smb2pdu.c:182:6: note: Left side of '||' is false
           if ((!tcon->ses) || (tcon->ses->status == CifsExiting) ||
               ^
   fs/cifs/smb2pdu.c:183:7: note: Assuming field 'server' is non-null
               (!tcon->ses->server) || !server)
                ^~~~~~~~~~~~~~~~~~
   fs/cifs/smb2pdu.c:182:6: note: Left side of '||' is false
           if ((!tcon->ses) || (tcon->ses->status == CifsExiting) ||
               ^
   fs/cifs/smb2pdu.c:183:30: note: Assuming 'server' is non-null
               (!tcon->ses->server) || !server)
                                       ^~~~~~~
   fs/cifs/smb2pdu.c:182:2: note: Taking false branch
           if ((!tcon->ses) || (tcon->ses->status == CifsExiting) ||
           ^
   fs/cifs/smb2pdu.c:194:9: note: Assuming field 'tcpStatus' is not equal to CifsNeedReconnect
           while (server->tcpStatus == CifsNeedReconnect) {
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/cifs/smb2pdu.c:194:2: note: Loop condition is false. Execution continues on line 242
           while (server->tcpStatus == CifsNeedReconnect) {
           ^
   fs/cifs/smb2pdu.c:243:6: note: Assuming the condition is false
           if (!cifs_chan_needs_reconnect(ses, server) && !tcon->need_reconnect) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/cifs/smb2pdu.c:243:46: note: Left side of '&&' is false
           if (!cifs_chan_needs_reconnect(ses, server) && !tcon->need_reconnect) {
                                                       ^
   fs/cifs/smb2pdu.c:247:2: note: Taking false branch
           cifs_dbg(FYI, "sess reconnect mask: 0x%lx, tcon reconnect: %d",
           ^
   fs/cifs/cifs_debug.h:76:2: note: expanded from macro 'cifs_dbg'
           if ((type) & ONCE)                                              \
           ^
   fs/cifs/smb2pdu.c:247:2: note: Left side of '&&' is true
           cifs_dbg(FYI, "sess reconnect mask: 0x%lx, tcon reconnect: %d",
           ^
   fs/cifs/cifs_debug.h:79:3: note: expanded from macro 'cifs_dbg'
                   cifs_dbg_func(ratelimited, type, fmt, ##__VA_ARGS__);   \
                   ^
   fs/cifs/cifs_debug.h:64:6: note: expanded from macro 'cifs_dbg_func'
           if ((type) & FYI && cifsFYI & CIFS_INFO) {                      \
               ^
   fs/cifs/smb2pdu.c:247:2: note: Assuming the condition is false
           cifs_dbg(FYI, "sess reconnect mask: 0x%lx, tcon reconnect: %d",
           ^
   fs/cifs/cifs_debug.h:79:3: note: expanded from macro 'cifs_dbg'
                   cifs_dbg_func(ratelimited, type, fmt, ##__VA_ARGS__);   \
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/cifs/cifs_debug.h:64:22: note: expanded from macro 'cifs_dbg_func'
           if ((type) & FYI && cifsFYI & CIFS_INFO) {                      \
                               ^~~~~~~~~~~~~~~~~~~
   fs/cifs/smb2pdu.c:247:2: note: Taking false branch
           cifs_dbg(FYI, "sess reconnect mask: 0x%lx, tcon reconnect: %d",
           ^
   fs/cifs/cifs_debug.h:79:3: note: expanded from macro 'cifs_dbg'
                   cifs_dbg_func(ratelimited, type, fmt, ##__VA_ARGS__);   \
                   ^
   fs/cifs/cifs_debug.h:64:2: note: expanded from macro 'cifs_dbg_func'
           if ((type) & FYI && cifsFYI & CIFS_INFO) {                      \
           ^
   fs/cifs/smb2pdu.c:247:2: note: Taking false branch
           cifs_dbg(FYI, "sess reconnect mask: 0x%lx, tcon reconnect: %d",
           ^
   fs/cifs/cifs_debug.h:79:3: note: expanded from macro 'cifs_dbg'

vim +341 fs/cifs/smb2pdu.c

ec2e4523fdba88 Pavel Shilovsky   2011-12-27  140  
ec2e4523fdba88 Pavel Shilovsky   2011-12-27  141  static int
352d96f3acc6e0 Aurelien Aptel    2020-05-31  142  smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
352d96f3acc6e0 Aurelien Aptel    2020-05-31  143  	       struct TCP_Server_Info *server)
ec2e4523fdba88 Pavel Shilovsky   2011-12-27  144  {
7ffbe65578b44f Paulo Alcantara   2018-07-05  145  	int rc;
aa24d1e9692411 Pavel Shilovsky   2011-12-27  146  	struct nls_table *nls_codepage;
aa24d1e9692411 Pavel Shilovsky   2011-12-27  147  	struct cifs_ses *ses;
a3a53b7603798f Paulo Alcantara   2018-11-14  148  	int retries;
aa24d1e9692411 Pavel Shilovsky   2011-12-27  149  
aa24d1e9692411 Pavel Shilovsky   2011-12-27  150  	/*
aa24d1e9692411 Pavel Shilovsky   2011-12-27  151  	 * SMB2s NegProt, SessSetup, Logoff do not have tcon yet so
aa24d1e9692411 Pavel Shilovsky   2011-12-27  152  	 * check for tcp and smb session status done differently
aa24d1e9692411 Pavel Shilovsky   2011-12-27  153  	 * for those three - in the calling routine.
aa24d1e9692411 Pavel Shilovsky   2011-12-27  154  	 */
aa24d1e9692411 Pavel Shilovsky   2011-12-27  155  	if (tcon == NULL)
7ffbe65578b44f Paulo Alcantara   2018-07-05  156  		return 0;
aa24d1e9692411 Pavel Shilovsky   2011-12-27  157  
c88f7dcd6d6429 Paulo Alcantara   2021-11-03  158  	/*
c88f7dcd6d6429 Paulo Alcantara   2021-11-03  159  	 * Need to also skip SMB2_IOCTL because it is used for checking nested dfs links in
c88f7dcd6d6429 Paulo Alcantara   2021-11-03  160  	 * cifs_tree_connect().
c88f7dcd6d6429 Paulo Alcantara   2021-11-03  161  	 */
c88f7dcd6d6429 Paulo Alcantara   2021-11-03  162  	if (smb2_command == SMB2_TREE_CONNECT || smb2_command == SMB2_IOCTL)
7ffbe65578b44f Paulo Alcantara   2018-07-05  163  		return 0;
aa24d1e9692411 Pavel Shilovsky   2011-12-27  164  
46c2db2a208986 Steve French      2021-11-19  165  	spin_lock(&cifs_tcp_ses_lock);
aa24d1e9692411 Pavel Shilovsky   2011-12-27  166  	if (tcon->tidStatus == CifsExiting) {
aa24d1e9692411 Pavel Shilovsky   2011-12-27  167  		/*
aa24d1e9692411 Pavel Shilovsky   2011-12-27  168  		 * only tree disconnect, open, and write,
aa24d1e9692411 Pavel Shilovsky   2011-12-27  169  		 * (and ulogoff which does not have tcon)
aa24d1e9692411 Pavel Shilovsky   2011-12-27  170  		 * are allowed as we start force umount.
aa24d1e9692411 Pavel Shilovsky   2011-12-27  171  		 */
aa24d1e9692411 Pavel Shilovsky   2011-12-27  172  		if ((smb2_command != SMB2_WRITE) &&
aa24d1e9692411 Pavel Shilovsky   2011-12-27  173  		   (smb2_command != SMB2_CREATE) &&
aa24d1e9692411 Pavel Shilovsky   2011-12-27  174  		   (smb2_command != SMB2_TREE_DISCONNECT)) {
46c2db2a208986 Steve French      2021-11-19  175  			spin_unlock(&cifs_tcp_ses_lock);
f96637be081141 Joe Perches       2013-05-04  176  			cifs_dbg(FYI, "can not send cmd %d while umounting\n",
aa24d1e9692411 Pavel Shilovsky   2011-12-27  177  				 smb2_command);
aa24d1e9692411 Pavel Shilovsky   2011-12-27  178  			return -ENODEV;
aa24d1e9692411 Pavel Shilovsky   2011-12-27  179  		}
aa24d1e9692411 Pavel Shilovsky   2011-12-27  180  	}
46c2db2a208986 Steve French      2021-11-19  181  	spin_unlock(&cifs_tcp_ses_lock);
aa24d1e9692411 Pavel Shilovsky   2011-12-27  182  	if ((!tcon->ses) || (tcon->ses->status == CifsExiting) ||
352d96f3acc6e0 Aurelien Aptel    2020-05-31  183  	    (!tcon->ses->server) || !server)
aa24d1e9692411 Pavel Shilovsky   2011-12-27  184  		return -EIO;
aa24d1e9692411 Pavel Shilovsky   2011-12-27  185  
aa24d1e9692411 Pavel Shilovsky   2011-12-27  186  	ses = tcon->ses;
a3a53b7603798f Paulo Alcantara   2018-11-14  187  	retries = server->nr_targets;
a3a53b7603798f Paulo Alcantara   2018-11-14  188  
aa24d1e9692411 Pavel Shilovsky   2011-12-27  189  	/*
a3a53b7603798f Paulo Alcantara   2018-11-14  190  	 * Give demultiplex thread up to 10 seconds to each target available for
a3a53b7603798f Paulo Alcantara   2018-11-14  191  	 * reconnect -- should be greater than cifs socket timeout which is 7
a3a53b7603798f Paulo Alcantara   2018-11-14  192  	 * seconds.
aa24d1e9692411 Pavel Shilovsky   2011-12-27  193  	 */
aa24d1e9692411 Pavel Shilovsky   2011-12-27  194  	while (server->tcpStatus == CifsNeedReconnect) {
aa24d1e9692411 Pavel Shilovsky   2011-12-27  195  		/*
aa24d1e9692411 Pavel Shilovsky   2011-12-27  196  		 * Return to caller for TREE_DISCONNECT and LOGOFF and CLOSE
aa24d1e9692411 Pavel Shilovsky   2011-12-27  197  		 * here since they are implicitly done when session drops.
aa24d1e9692411 Pavel Shilovsky   2011-12-27  198  		 */
aa24d1e9692411 Pavel Shilovsky   2011-12-27  199  		switch (smb2_command) {
aa24d1e9692411 Pavel Shilovsky   2011-12-27  200  		/*
aa24d1e9692411 Pavel Shilovsky   2011-12-27  201  		 * BB Should we keep oplock break and add flush to exceptions?
aa24d1e9692411 Pavel Shilovsky   2011-12-27  202  		 */
aa24d1e9692411 Pavel Shilovsky   2011-12-27  203  		case SMB2_TREE_DISCONNECT:
aa24d1e9692411 Pavel Shilovsky   2011-12-27  204  		case SMB2_CANCEL:
aa24d1e9692411 Pavel Shilovsky   2011-12-27  205  		case SMB2_CLOSE:
aa24d1e9692411 Pavel Shilovsky   2011-12-27  206  		case SMB2_OPLOCK_BREAK:
aa24d1e9692411 Pavel Shilovsky   2011-12-27  207  			return -EAGAIN;
aa24d1e9692411 Pavel Shilovsky   2011-12-27  208  		}
aa24d1e9692411 Pavel Shilovsky   2011-12-27  209  
7ffbe65578b44f Paulo Alcantara   2018-07-05  210  		rc = wait_event_interruptible_timeout(server->response_q,
7ffbe65578b44f Paulo Alcantara   2018-07-05  211  						      (server->tcpStatus != CifsNeedReconnect),
7ffbe65578b44f Paulo Alcantara   2018-07-05  212  						      10 * HZ);
7ffbe65578b44f Paulo Alcantara   2018-07-05  213  		if (rc < 0) {
a0a3036b81f1f6 Joe Perches       2020-04-14  214  			cifs_dbg(FYI, "%s: aborting reconnect due to a received signal by the process\n",
a0a3036b81f1f6 Joe Perches       2020-04-14  215  				 __func__);
7ffbe65578b44f Paulo Alcantara   2018-07-05  216  			return -ERESTARTSYS;
7ffbe65578b44f Paulo Alcantara   2018-07-05  217  		}
aa24d1e9692411 Pavel Shilovsky   2011-12-27  218  
aa24d1e9692411 Pavel Shilovsky   2011-12-27  219  		/* are we still trying to reconnect? */
46c2db2a208986 Steve French      2021-11-19  220  		spin_lock(&cifs_tcp_ses_lock);
46c2db2a208986 Steve French      2021-11-19  221  		if (server->tcpStatus != CifsNeedReconnect) {
46c2db2a208986 Steve French      2021-11-19  222  			spin_unlock(&cifs_tcp_ses_lock);
aa24d1e9692411 Pavel Shilovsky   2011-12-27  223  			break;
46c2db2a208986 Steve French      2021-11-19  224  		}
46c2db2a208986 Steve French      2021-11-19  225  		spin_unlock(&cifs_tcp_ses_lock);
aa24d1e9692411 Pavel Shilovsky   2011-12-27  226  
c54849ddd832ae Ronnie Sahlberg   2020-01-31  227  		if (retries && --retries)
a3a53b7603798f Paulo Alcantara   2018-11-14  228  			continue;
a3a53b7603798f Paulo Alcantara   2018-11-14  229  
aa24d1e9692411 Pavel Shilovsky   2011-12-27  230  		/*
aa24d1e9692411 Pavel Shilovsky   2011-12-27  231  		 * on "soft" mounts we wait once. Hard mounts keep
aa24d1e9692411 Pavel Shilovsky   2011-12-27  232  		 * retrying until process is killed or server comes
aa24d1e9692411 Pavel Shilovsky   2011-12-27  233  		 * back on-line
aa24d1e9692411 Pavel Shilovsky   2011-12-27  234  		 */
aa24d1e9692411 Pavel Shilovsky   2011-12-27  235  		if (!tcon->retry) {
f96637be081141 Joe Perches       2013-05-04  236  			cifs_dbg(FYI, "gave up waiting on reconnect in smb_init\n");
aa24d1e9692411 Pavel Shilovsky   2011-12-27  237  			return -EHOSTDOWN;
aa24d1e9692411 Pavel Shilovsky   2011-12-27  238  		}
a3a53b7603798f Paulo Alcantara   2018-11-14  239  		retries = server->nr_targets;
aa24d1e9692411 Pavel Shilovsky   2011-12-27  240  	}
aa24d1e9692411 Pavel Shilovsky   2011-12-27  241  
2e1950bf3a3683 Steve French      2021-11-19  242  	spin_lock(&ses->chan_lock);
2e1950bf3a3683 Steve French      2021-11-19  243  	if (!cifs_chan_needs_reconnect(ses, server) && !tcon->need_reconnect) {
2e1950bf3a3683 Steve French      2021-11-19  244  		spin_unlock(&ses->chan_lock);
7ffbe65578b44f Paulo Alcantara   2018-07-05  245  		return 0;
2e1950bf3a3683 Steve French      2021-11-19  246  	}
2e1950bf3a3683 Steve French      2021-11-19  247  	cifs_dbg(FYI, "sess reconnect mask: 0x%lx, tcon reconnect: %d",
2e1950bf3a3683 Steve French      2021-11-19  248  		 tcon->ses->chans_need_reconnect,
2e1950bf3a3683 Steve French      2021-11-19  249  		 tcon->need_reconnect);
2e1950bf3a3683 Steve French      2021-11-19  250  	spin_unlock(&ses->chan_lock);
aa24d1e9692411 Pavel Shilovsky   2011-12-27  251  
aa24d1e9692411 Pavel Shilovsky   2011-12-27  252  	nls_codepage = load_nls_default();
aa24d1e9692411 Pavel Shilovsky   2011-12-27  253  
76e752701a8af4 Samuel Cabrero    2017-07-11  254  	/*
76e752701a8af4 Samuel Cabrero    2017-07-11  255  	 * Recheck after acquire mutex. If another thread is negotiating
76e752701a8af4 Samuel Cabrero    2017-07-11  256  	 * and the server never sends an answer the socket will be closed
76e752701a8af4 Samuel Cabrero    2017-07-11  257  	 * and tcpStatus set to reconnect.
76e752701a8af4 Samuel Cabrero    2017-07-11  258  	 */
46c2db2a208986 Steve French      2021-11-19  259  	spin_lock(&cifs_tcp_ses_lock);
76e752701a8af4 Samuel Cabrero    2017-07-11  260  	if (server->tcpStatus == CifsNeedReconnect) {
46c2db2a208986 Steve French      2021-11-19  261  		spin_unlock(&cifs_tcp_ses_lock);
76e752701a8af4 Samuel Cabrero    2017-07-11  262  		rc = -EHOSTDOWN;
76e752701a8af4 Samuel Cabrero    2017-07-11  263  		goto out;
76e752701a8af4 Samuel Cabrero    2017-07-11  264  	}
46c2db2a208986 Steve French      2021-11-19  265  	spin_unlock(&cifs_tcp_ses_lock);
76e752701a8af4 Samuel Cabrero    2017-07-11  266  
2e1950bf3a3683 Steve French      2021-11-19  267  	/*
2e1950bf3a3683 Steve French      2021-11-19  268  	 * need to prevent multiple threads trying to simultaneously
2e1950bf3a3683 Steve French      2021-11-19  269  	 * reconnect the same SMB session
2e1950bf3a3683 Steve French      2021-11-19  270  	 */
2e1950bf3a3683 Steve French      2021-11-19  271  	spin_lock(&ses->chan_lock);
2e1950bf3a3683 Steve French      2021-11-19  272  	if (!cifs_chan_needs_reconnect(ses, server)) {
2e1950bf3a3683 Steve French      2021-11-19  273  		spin_unlock(&ses->chan_lock);
2e1950bf3a3683 Steve French      2021-11-19  274  
0d0119cf6ce4eb Steve French      2021-11-19  275  		/* this means that we only need to tree connect */
2e1950bf3a3683 Steve French      2021-11-19  276  		if (tcon->need_reconnect)
2e1950bf3a3683 Steve French      2021-11-19  277  			goto skip_sess_setup;
2e1950bf3a3683 Steve French      2021-11-19  278  
2e1950bf3a3683 Steve French      2021-11-19  279  		goto out;
2e1950bf3a3683 Steve French      2021-11-19  280  	}
2e1950bf3a3683 Steve French      2021-11-19  281  	spin_unlock(&ses->chan_lock);
2e1950bf3a3683 Steve French      2021-11-19  282  
b8272812b48c94 Shyam Prasad N    2021-07-19  283  	mutex_lock(&ses->session_mutex);
0d0119cf6ce4eb Steve French      2021-11-19  284  	rc = cifs_negotiate_protocol(0, ses, server);
2e1950bf3a3683 Steve French      2021-11-19  285  	if (!rc) {
0d0119cf6ce4eb Steve French      2021-11-19  286  		rc = cifs_setup_session(0, ses, server, nls_codepage);
b0dd940e582b6a Ronnie Sahlberg   2020-02-05  287  		if ((rc == -EACCES) && !tcon->retry) {
0d0119cf6ce4eb Steve French      2021-11-19  288  			mutex_unlock(&ses->session_mutex);
b8272812b48c94 Shyam Prasad N    2021-07-19  289  			rc = -EHOSTDOWN;
b0dd940e582b6a Ronnie Sahlberg   2020-02-05  290  			goto failed;
b0dd940e582b6a Ronnie Sahlberg   2020-02-05  291  		}
b0dd940e582b6a Ronnie Sahlberg   2020-02-05  292  	}
2f58967979409e Aurelien Aptel    2020-04-24  293  
aa24d1e9692411 Pavel Shilovsky   2011-12-27  294  	if (rc || !tcon->need_reconnect) {
b8272812b48c94 Shyam Prasad N    2021-07-19  295  		mutex_unlock(&ses->session_mutex);
aa24d1e9692411 Pavel Shilovsky   2011-12-27  296  		goto out;
aa24d1e9692411 Pavel Shilovsky   2011-12-27  297  	}
aa24d1e9692411 Pavel Shilovsky   2011-12-27  298  
2e1950bf3a3683 Steve French      2021-11-19  299  skip_sess_setup:
aa24d1e9692411 Pavel Shilovsky   2011-12-27  300  	cifs_mark_open_files_invalid(tcon);
96a988ffeb90db Pavel Shilovsky   2016-11-29  301  	if (tcon->use_persistent)
96a988ffeb90db Pavel Shilovsky   2016-11-29  302  		tcon->need_reopen_files = true;
52ace1ef1259e1 Steve French      2016-09-22  303  
565674d613d7f4 Stefan Metzmacher 2020-07-21  304  	rc = cifs_tree_connect(0, tcon, nls_codepage);
b8272812b48c94 Shyam Prasad N    2021-07-19  305  	mutex_unlock(&ses->session_mutex);
52ace1ef1259e1 Steve French      2016-09-22  306  
f96637be081141 Joe Perches       2013-05-04  307  	cifs_dbg(FYI, "reconnect tcon rc = %d\n", rc);
c318e6c26cbe91 Steve French      2018-04-04  308  	if (rc) {
c318e6c26cbe91 Steve French      2018-04-04  309  		/* If sess reconnected but tcon didn't, something strange ... */
a0a3036b81f1f6 Joe Perches       2020-04-14  310  		pr_warn_once("reconnect tcon failed rc = %d\n", rc);
aa24d1e9692411 Pavel Shilovsky   2011-12-27  311  		goto out;
c318e6c26cbe91 Steve French      2018-04-04  312  	}
96a988ffeb90db Pavel Shilovsky   2016-11-29  313  
96a988ffeb90db Pavel Shilovsky   2016-11-29  314  	if (smb2_command != SMB2_INTERNAL_CMD)
b08484d715128a Stefan Metzmacher 2020-02-24  315  		mod_delayed_work(cifsiod_wq, &server->reconnect, 0);
96a988ffeb90db Pavel Shilovsky   2016-11-29  316  
aa24d1e9692411 Pavel Shilovsky   2011-12-27  317  	atomic_inc(&tconInfoReconnectCount);
aa24d1e9692411 Pavel Shilovsky   2011-12-27  318  out:
aa24d1e9692411 Pavel Shilovsky   2011-12-27  319  	/*
aa24d1e9692411 Pavel Shilovsky   2011-12-27  320  	 * Check if handle based operation so we know whether we can continue
aa24d1e9692411 Pavel Shilovsky   2011-12-27  321  	 * or not without returning to caller to reset file handle.
aa24d1e9692411 Pavel Shilovsky   2011-12-27  322  	 */
aa24d1e9692411 Pavel Shilovsky   2011-12-27  323  	/*
aa24d1e9692411 Pavel Shilovsky   2011-12-27  324  	 * BB Is flush done by server on drop of tcp session? Should we special
aa24d1e9692411 Pavel Shilovsky   2011-12-27  325  	 * case it and skip above?
aa24d1e9692411 Pavel Shilovsky   2011-12-27  326  	 */
aa24d1e9692411 Pavel Shilovsky   2011-12-27  327  	switch (smb2_command) {
aa24d1e9692411 Pavel Shilovsky   2011-12-27  328  	case SMB2_FLUSH:
aa24d1e9692411 Pavel Shilovsky   2011-12-27  329  	case SMB2_READ:
aa24d1e9692411 Pavel Shilovsky   2011-12-27  330  	case SMB2_WRITE:
aa24d1e9692411 Pavel Shilovsky   2011-12-27  331  	case SMB2_LOCK:
aa24d1e9692411 Pavel Shilovsky   2011-12-27  332  	case SMB2_IOCTL:
aa24d1e9692411 Pavel Shilovsky   2011-12-27  333  	case SMB2_QUERY_DIRECTORY:
aa24d1e9692411 Pavel Shilovsky   2011-12-27  334  	case SMB2_CHANGE_NOTIFY:
aa24d1e9692411 Pavel Shilovsky   2011-12-27  335  	case SMB2_QUERY_INFO:
aa24d1e9692411 Pavel Shilovsky   2011-12-27  336  	case SMB2_SET_INFO:
4772c79599564b Pavel Shilovsky   2016-11-29  337  		rc = -EAGAIN;
aa24d1e9692411 Pavel Shilovsky   2011-12-27  338  	}
b0dd940e582b6a Ronnie Sahlberg   2020-02-05  339  failed:
aa24d1e9692411 Pavel Shilovsky   2011-12-27  340  	unload_nls(nls_codepage);
ec2e4523fdba88 Pavel Shilovsky   2011-12-27 @341  	return rc;
ec2e4523fdba88 Pavel Shilovsky   2011-12-27  342  }
ec2e4523fdba88 Pavel Shilovsky   2011-12-27  343  

:::::: The code at line 341 was first introduced by commit
:::::: ec2e4523fdba88317e06d0c7a88af3a0860447fc CIFS: Add capability to send SMB2 negotiate message

:::::: TO: Pavel Shilovsky <piastry@etersoft.ru>
:::::: CC: Pavel Shilovsky <pshilovsky@samba.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 32041 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-21  6:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-21  6:53 [smfrench-smb3:for-next 14/18] fs/cifs/smb2pdu.c:341:2: warning: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn] kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.