Skip to content

Commit

Permalink
smb: client: fix potential UAF in cifs_dump_full_key()
Browse files Browse the repository at this point in the history
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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
pcacjr authored and gregkh committed Apr 10, 2024
1 parent 1e12f0d commit 3103163
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/smb/client/ioctl.c
Expand Up @@ -247,17 +247,21 @@ static int cifs_dump_full_key(struct cifs_tcon *tcon, struct smb3_full_key_debug
spin_lock(&cifs_tcp_ses_lock);
list_for_each_entry(server_it, &cifs_tcp_ses_list, tcp_ses_list) {
list_for_each_entry(ses_it, &server_it->smb_ses_list, smb_ses_list) {
if (ses_it->Suid == out.session_id) {
spin_lock(&ses_it->ses_lock);
if (ses_it->ses_status != SES_EXITING &&
ses_it->Suid == out.session_id) {
ses = ses_it;
/*
* since we are using the session outside the crit
* section, we need to make sure it won't be released
* so increment its refcount
*/
cifs_smb_ses_inc_refcount(ses);
spin_unlock(&ses_it->ses_lock);
found = true;
goto search_end;
}
spin_unlock(&ses_it->ses_lock);
}
}
search_end:
Expand Down

0 comments on commit 3103163

Please sign in to comment.