cifs: fix panic in smb2_reconnect
Subsystems (3)
PATCH 1/1 cifs: fix panic in smb2_reconnect
RH Bugzilla: 1702264
We need to protect so that the call to smb2_reconnect() in smb2_reconnect_server() does not end up freeing the session because it can lead to a use after free and crash.
--- fs/cifs/smb2pdu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/cifs/smb2pdu.c +9 -1
@@ -3113,9 +3113,14 @@ void smb2_reconnect_server(struct work_struct *work) tcon_exist = true; } } +/* +* IPC has the same lifetime as its session and uses its +* refcount. +*/ if (ses->tcon_ipc && ses->tcon_ipc->need_reconnect) {list_add_tail (&ses->tcon_ipc->rlist, &tmp_list); tcon_exist = true; + ses->ses_count++; } }/*
@@ -3134,7 +3139,10 @@ void smb2_reconnect_server(struct work_struct *work)else resched = true;list_del_init (&tcon->rlist); -cifs_put_tcon (tcon); +if (tcon->ipc) +cifs_put_smb_ses (tcon->ses); +else +cifs_put_tcon (tcon); }cifs_dbg (FYI ,"Reconnecting tcons finished\n" );
Signature · 1 line
2.13.6
tentatively merged into cifs-2.6.git for-next (and to the github tree for next buildbot run)
Quoted 48 lines · Ronnie Sahlberg
RH Bugzilla: 1702264
We need to protect so that the call to
smb2_reconnect()insmb2_reconnect_server()does not end up freeing the session because it can lead to a use after free and crash.Reviewed-by Aurelien Aptel <[email protected]>Cc <[email protected]>Signed-off-by Ronnie Sahlberg <[email protected]>--- fs/cifs/smb2pdu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)fs/cifs/smb2pdu.c +9
-2@@ -3113,9 +3113,14 @@ void smb2_reconnect_server(struct work_struct *work) tcon_exist = true; } } +/* +* IPC has the same lifetime as its session and uses its +* refcount. +*/ if (ses->tcon_ipc && ses->tcon_ipc->need_reconnect) {list_add_tail (&ses->tcon_ipc->rlist, &tmp_list); tcon_exist = true; + ses->ses_count++; } }/* @@ -3134,7 +3139,10 @@ void smb2_reconnect_server(struct work_struct *work)else resched = true;list_del_init (&tcon->rlist); -cifs_put_tcon (tcon); +if (tcon->ipc) +cifs_put_smb_ses (tcon->ses); +else +cifs_put_tcon (tcon); }cifs_dbg (FYI ,"Reconnecting tcons finished\n" ); --2.13.6
Signature · 3 lines
Thanks, Steve
вт, 4 июн. 2019 г. в 17:16, Ronnie Sahlberg <[email protected]>:
Quoted 46 lines
RH Bugzilla: 1702264
We need to protect so that the call to
smb2_reconnect()insmb2_reconnect_server()does not end up freeing the session because it can lead to a use after free and crash.Reviewed-by Aurelien Aptel <[email protected]>Cc <[email protected]>Signed-off-by Ronnie Sahlberg <[email protected]>--- fs/cifs/smb2pdu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)fs/cifs/smb2pdu.c +9
-2@@ -3113,9 +3113,14 @@ void smb2_reconnect_server(struct work_struct *work) tcon_exist = true; } } +/* +* IPC has the same lifetime as its session and uses its +* refcount. +*/ if (ses->tcon_ipc && ses->tcon_ipc->need_reconnect) {list_add_tail (&ses->tcon_ipc->rlist, &tmp_list); tcon_exist = true; + ses->ses_count++; } }/* @@ -3134,7 +3139,10 @@ void smb2_reconnect_server(struct work_struct *work)else resched = true;list_del_init (&tcon->rlist); -cifs_put_tcon (tcon); +if (tcon->ipc) +cifs_put_smb_ses (tcon->ses); +else +cifs_put_tcon (tcon); }cifs_dbg (FYI ,"Reconnecting tcons finished\n" ); --
Quoted 2 lines
2.13.6
--
Best regards,
Pavel Shilovsky