Skip to content

Commit f4a60d3

Browse files
Paulo Alcantaragregkh
authored andcommitted
smb: client: fix potential UAF in cifs_dump_full_key()
commit 58acd1f upstream. Skip sessions that are being teared down (status == SES_EXITING) to avoid UAF. Cc: stable@vger.kernel.org Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.com> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Jianqi Ren <jianqi.ren.cn@windriver.com> Signed-off-by: He Zhe <zhe.he@windriver.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e0a545b commit f4a60d3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

fs/smb/client/ioctl.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,17 +246,21 @@ static int cifs_dump_full_key(struct cifs_tcon *tcon, struct smb3_full_key_debug
246246
spin_lock(&cifs_tcp_ses_lock);
247247
list_for_each_entry(server_it, &cifs_tcp_ses_list, tcp_ses_list) {
248248
list_for_each_entry(ses_it, &server_it->smb_ses_list, smb_ses_list) {
249-
if (ses_it->Suid == out.session_id) {
249+
spin_lock(&ses_it->ses_lock);
250+
if (ses_it->ses_status != SES_EXITING &&
251+
ses_it->Suid == out.session_id) {
250252
ses = ses_it;
251253
/*
252254
* since we are using the session outside the crit
253255
* section, we need to make sure it won't be released
254256
* so increment its refcount
255257
*/
256258
ses->ses_count++;
259+
spin_unlock(&ses_it->ses_lock);
257260
found = true;
258261
goto search_end;
259262
}
263+
spin_unlock(&ses_it->ses_lock);
260264
}
261265
}
262266
search_end:

0 commit comments

Comments
 (0)