Skip to content

Commit

Permalink
cifs: fix panic in smb2_reconnect
Browse files Browse the repository at this point in the history
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.

Reviewed-by: Aurelien Aptel <[email protected]>
Cc: <[email protected]>
Signed-off-by: Ronnie Sahlberg <[email protected]>
Signed-off-by: Steve French <[email protected]>
Reviewed-by: Pavel Shilovsky <[email protected]>
  • Loading branch information
Ronnie Sahlberg authored and Steve French committed Jun 13, 2019
1 parent d1fdb6d commit 0ff2b01
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fs/cifs/smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3114,9 +3114,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++;
}
}
/*
Expand All @@ -3135,7 +3140,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");
Expand Down

0 comments on commit 0ff2b01

Please sign in to comment.