Skip to content

Commit 99f2807

Browse files
winnscodesmfrench
authored andcommitted
cifs: fix session state check in reconnect to avoid use-after-free issue
Don't collect exiting session in smb2_reconnect_server(), because it will be released soon. Note that the exiting session will stay in server->smb_ses_list until it complete the cifs_free_ipc() and logoff() and then delete itself from the list. Signed-off-by: Winston Wen <[email protected]> Reviewed-by: Shyam Prasad N <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 326a8d0 commit 99f2807

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/smb/client/smb2pdu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3797,6 +3797,12 @@ void smb2_reconnect_server(struct work_struct *work)
37973797

37983798
spin_lock(&cifs_tcp_ses_lock);
37993799
list_for_each_entry(ses, &pserver->smb_ses_list, smb_ses_list) {
3800+
spin_lock(&ses->ses_lock);
3801+
if (ses->ses_status == SES_EXITING) {
3802+
spin_unlock(&ses->ses_lock);
3803+
continue;
3804+
}
3805+
spin_unlock(&ses->ses_lock);
38003806

38013807
tcon_selected = false;
38023808

0 commit comments

Comments
 (0)