Skip to content

Commit 7257bcf

Browse files
sprasad-microsoftSteve French
authored andcommitted
cifs: cifs_chan_is_iface_active should be called with chan_lock held
cifs_chan_is_iface_active checks the channels of a session to see if the associated iface is active. This should always happen with chan_lock held. However, these two callers of this function were missing this locking. This change makes sure the function calls are protected with proper locking. Fixes: b54034a ("cifs: during reconnect, update interface if necessary") Fixes: fa1d050 ("cifs: account for primary channel in the interface list") Cc: stable@vger.kernel.org Signed-off-by: Shyam Prasad N <sprasad@microsoft.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 27e1fd3 commit 7257bcf

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

fs/smb/client/connect.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,13 @@ cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
232232
spin_lock(&cifs_tcp_ses_lock);
233233
list_for_each_entry_safe(ses, nses, &pserver->smb_ses_list, smb_ses_list) {
234234
/* check if iface is still active */
235-
if (!cifs_chan_is_iface_active(ses, server))
235+
spin_lock(&ses->chan_lock);
236+
if (!cifs_chan_is_iface_active(ses, server)) {
237+
spin_unlock(&ses->chan_lock);
236238
cifs_chan_update_iface(ses, server);
239+
spin_lock(&ses->chan_lock);
240+
}
237241

238-
spin_lock(&ses->chan_lock);
239242
if (!mark_smb_session && cifs_chan_needs_reconnect(ses, server)) {
240243
spin_unlock(&ses->chan_lock);
241244
continue;

fs/smb/client/smb2ops.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,14 @@ SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_
784784
goto out;
785785

786786
/* check if iface is still active */
787+
spin_lock(&ses->chan_lock);
787788
pserver = ses->chans[0].server;
788-
if (pserver && !cifs_chan_is_iface_active(ses, pserver))
789+
if (pserver && !cifs_chan_is_iface_active(ses, pserver)) {
790+
spin_unlock(&ses->chan_lock);
789791
cifs_chan_update_iface(ses, pserver);
792+
spin_lock(&ses->chan_lock);
793+
}
794+
spin_unlock(&ses->chan_lock);
790795

791796
out:
792797
kfree(out_buf);

0 commit comments

Comments
 (0)