Skip to content

Commit 0060a4f

Browse files
committed
cifs: fix missing spinlock around update to ses->status
In the other places where we update ses->status we protect the updates via GlobalMid_Lock. So to be consistent add the same locking around it in cifs_put_smb_ses where it was missing. Addresses-Coverity: 1268904 ("Data race condition") Signed-off-by: Steve French <[email protected]>
1 parent 162004a commit 0060a4f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

fs/cifs/cifsglob.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ struct cifs_ses {
887887
struct mutex session_mutex;
888888
struct TCP_Server_Info *server; /* pointer to server info */
889889
int ses_count; /* reference counter */
890-
enum statusEnum status;
890+
enum statusEnum status; /* updates protected by GlobalMid_Lock */
891891
unsigned overrideSecFlg; /* if non-zero override global sec flags */
892892
char *serverOS; /* name of operating system underlying server */
893893
char *serverNOS; /* name of network operating system of server */
@@ -1785,6 +1785,7 @@ require use of the stronger protocol */
17851785
* list operations on pending_mid_q and oplockQ
17861786
* updates to XID counters, multiplex id and SMB sequence numbers
17871787
* list operations on global DnotifyReqList
1788+
* updates to ses->status
17881789
* tcp_ses_lock protects:
17891790
* list operations on tcp and SMB session lists
17901791
* tcon->open_file_lock protects the list of open files hanging off the tcon

fs/cifs/connect.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,9 +1598,12 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
15981598
spin_unlock(&cifs_tcp_ses_lock);
15991599
return;
16001600
}
1601+
spin_unlock(&cifs_tcp_ses_lock);
1602+
1603+
spin_lock(&GlobalMid_Lock);
16011604
if (ses->status == CifsGood)
16021605
ses->status = CifsExiting;
1603-
spin_unlock(&cifs_tcp_ses_lock);
1606+
spin_unlock(&GlobalMid_Lock);
16041607

16051608
cifs_free_ipc(ses);
16061609

0 commit comments

Comments
 (0)