Skip to content

Commit 58acd1f

Browse files
Paulo AlcantaraSteve French
authored andcommitted
smb: client: fix potential UAF in cifs_dump_full_key()
Skip sessions that are being teared down (status == SES_EXITING) to avoid UAF. Cc: [email protected] Signed-off-by: Paulo Alcantara (Red Hat) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent ca545b7 commit 58acd1f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/smb/client/ioctl.c

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

0 commit comments

Comments
 (0)