diff options
author | Shyam Prasad N <sprasad@microsoft.com> | 2021-11-19 14:16:57 +0000 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2022-01-19 11:10:54 -0600 |
commit | 88b024f556fcd5bf1288c6333016f576cfa5f539 (patch) | |
tree | 26e936c19c55aa2484d3ae6c4c23e9fde3ff0d2d /fs/cifs/connect.c | |
parent | a05885ce13bd5ec9602551e32dfb1a4f26bfa542 (diff) | |
download | linux-stable-88b024f556fcd5bf1288c6333016f576cfa5f539.tar.gz linux-stable-88b024f556fcd5bf1288c6333016f576cfa5f539.tar.bz2 linux-stable-88b024f556fcd5bf1288c6333016f576cfa5f539.zip |
cifs: protect all accesses to chan_* with chan_lock
A spin lock called chan_lock was introduced recently.
But not all accesses were protected. Doing that with
this change.
To make sure that a channel is not freed when in use,
we need to introduce a ref count. But today, we don't
ever free channels.
Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r-- | fs/cifs/connect.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 9fba2ec56328..d643f9e16f4e 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1831,7 +1831,6 @@ void cifs_put_smb_ses(struct cifs_ses *ses) spin_lock(&ses->chan_lock); chan_count = ses->chan_count; - spin_unlock(&ses->chan_lock); /* close any extra channels */ if (chan_count > 1) { @@ -1848,6 +1847,7 @@ void cifs_put_smb_ses(struct cifs_ses *ses) ses->chans[i].server = NULL; } } + spin_unlock(&ses->chan_lock); sesInfoFree(ses); cifs_put_tcp_session(server, 0); @@ -2123,8 +2123,10 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx) mutex_unlock(&ses->session_mutex); /* each channel uses a different signing key */ + spin_lock(&ses->chan_lock); memcpy(ses->chans[0].signkey, ses->smb3signingkey, sizeof(ses->smb3signingkey)); + spin_unlock(&ses->chan_lock); if (rc) goto get_ses_fail; |