]> git.itanic.dy.fi Git - linux-stable/commitdiff
smb: client: fix potential UAF in smb2_is_valid_lease_break()
authorPaulo Alcantara <pc@manguebit.com>
Tue, 2 Apr 2024 19:33:58 +0000 (16:33 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:38:21 +0000 (16:38 +0200)
commit 705c76fbf726c7a2f6ff9143d4013b18daaaebf1 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>
fs/smb/client/smb2misc.c

index 3f4c37458f97e881cebe53a80e60a07aecd2dc1c..cc72be5a93a933b09c45256c2a7d7615478f54c0 100644 (file)
@@ -622,6 +622,8 @@ smb2_is_valid_lease_break(char *buffer, struct TCP_Server_Info *server)
        /* look up tcon based on tid & uid */
        spin_lock(&cifs_tcp_ses_lock);
        list_for_each_entry(ses, &pserver->smb_ses_list, smb_ses_list) {
+               if (cifs_ses_exiting(ses))
+                       continue;
                list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
                        spin_lock(&tcon->open_file_lock);
                        cifs_stats_inc(