summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorWinston Wen <wentao@uniontech.com>2023-06-26 11:42:56 +0800
committerSteve French <stfrench@microsoft.com>2023-06-28 11:47:43 -0500
commit99f280700b4cc02d5f141b8d15f8e9fad0418f65 (patch)
tree84f9cfb541e42f7ef8f5400dd7fbac801e449dad /fs
parent326a8d04f147e2bf393f6f9cdb74126ee6900607 (diff)
downloadlinux-rpi-99f280700b4cc02d5f141b8d15f8e9fad0418f65.tar.gz
linux-rpi-99f280700b4cc02d5f141b8d15f8e9fad0418f65.tar.bz2
linux-rpi-99f280700b4cc02d5f141b8d15f8e9fad0418f65.zip
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 <wentao@uniontech.com> Reviewed-by: Shyam Prasad N <sprasad@microsoft.com> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/smb/client/smb2pdu.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 17fe212ab895..e04766fe6f80 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -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;