Skip to contentSkip to conversation

fs/smb/client/sess.c:323 cifs_disable_secondary_channels() error: dereferencing freed memory 'iface'

PATCH kernel test robot 1 participant 1 message Nov 11, 2023

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw

BCC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Shyam Prasad N <[email protected]>
CC: Steve French <[email protected]>

tree:   git://git.samba.org/sfrench/cifs-2.6.git for-next
head:   fd2bd7c0539e28f267a84da8d68f9378511b50a7
commit: aa52cd09620b0ebd34ccae0e7f9f5b773497a499 [8/13] cifs: handle when server stops supporting multichannel

:::::: branch date: 9 hours ago
:::::: commit date: 3 days ago
config: i386-randconfig-141-20231108 (https://download.01.org/0day-ci/archive/20231111/[email protected]/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce: (https://download.01.org/0day-ci/archive/20231111/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
fs/smb/client/sess.c:323 cifs_disable_secondary_channels() error: dereferencing freed memory 'iface'

vim +/iface +323 fs/smb/client/sess.c

d70e9fa5588476 fs/cifs/sess.c       Aurelien Aptel 2019-09-20  292  
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  293  /*
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  294   * called when multichannel is disabled by the server.
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  295   * this always gets called from smb2_reconnect
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  296   * and cannot get called in parallel threads.
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  297   */
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  298  void
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  299  cifs_disable_secondary_channels(struct cifs_ses *ses)
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  300  {
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  301  	int i, chan_count;
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  302  	struct TCP_Server_Info *server;
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  303  	struct cifs_server_iface *iface;
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  304  
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  305  	spin_lock(&ses->chan_lock);
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  306  	chan_count = ses->chan_count;
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  307  	if (chan_count == 1)
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  308  		goto done;
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  309  
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  310  	ses->chan_count = 1;
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  311  
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  312  	/* for all secondary channels reset the need reconnect bit */
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  313  	ses->chans_need_reconnect &= 1;
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  314  
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  315  	for (i = 1; i < chan_count; i++) {
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  316  		iface = ses->chans[i].iface;
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  317  		server = ses->chans[i].server;
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  318  
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  319  		if (iface) {
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  320  			spin_lock(&ses->iface_lock);
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  321  			kref_put(&iface->refcount, release_iface);
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  322  			ses->chans[i].iface = NULL;
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13 @323  			iface->num_channels--;
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  324  			if (iface->weight_fulfilled)
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  325  				iface->weight_fulfilled--;
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  326  			spin_unlock(&ses->iface_lock);
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  327  		}
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  328  
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  329  		spin_unlock(&ses->chan_lock);
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  330  		if (server && !server->terminate) {
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  331  			server->terminate = true;
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  332  			cifs_signal_cifsd_for_reconnect(server, false);
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  333  		}
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  334  		spin_lock(&ses->chan_lock);
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  335  
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  336  		if (server) {
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  337  			ses->chans[i].server = NULL;
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  338  			cifs_put_tcp_session(server, false);
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  339  		}
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  340  
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  341  	}
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  342  
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  343  done:
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  344  	spin_unlock(&ses->chan_lock);
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  345  }
aa52cd09620b0e fs/smb/client/sess.c Shyam Prasad N 2023-10-13  346  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki