]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: client: fix potential UAF in cifs_dump_full_key()
authorPaulo Alcantara <pc@manguebit.com>
Tue, 2 Apr 2024 19:33:54 +0000 (16:33 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 May 2025 05:44:20 +0000 (07:44 +0200)
commit 58acd1f497162e7d282077f816faa519487be045 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>
[ This patch removes lock/unlock operation in routine cifs_dump_full_key()
  for ses_lock is not present in v5.15 and not ported yet. ses->status
  is protected by a global lock, cifs_tcp_ses_lock, in v5.15.  ]
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>
fs/cifs/ioctl.c

index 71883ba9e5677c21f79defbe9072ca08d9844bef..e846c18b71d2db262a633f6814900cc44d1827af 100644 (file)
@@ -232,7 +232,8 @@ 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) {
+                               if (ses_it->status != CifsExiting &&
+                                   ses_it->Suid == out.session_id) {
                                        ses = ses_it;
                                        /*
                                         * since we are using the session outside the crit