Skip to content

Commit

Permalink
cifs: fix session state check in reconnect to avoid use-after-free issue
Browse files Browse the repository at this point in the history
[ Upstream commit 99f2807 ]

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 <wentao@uniontech.com>
Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
winnscode authored and gregkh committed Aug 23, 2023
1 parent eb79f8d commit 759ffc1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/smb/client/smb2pdu.c
Expand Up @@ -3797,6 +3797,12 @@ void smb2_reconnect_server(struct work_struct *work)

spin_lock(&cifs_tcp_ses_lock);
list_for_each_entry(ses, &pserver->smb_ses_list, smb_ses_list) {
spin_lock(&ses->ses_lock);
if (ses->ses_status == SES_EXITING) {
spin_unlock(&ses->ses_lock);
continue;
}
spin_unlock(&ses->ses_lock);

tcon_selected = false;

Expand Down

0 comments on commit 759ffc1

Please sign in to comment.