]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: client: fix potential UAF in cifs_debug_files_proc_show()
authorPaulo Alcantara <pc@manguebit.com>
Tue, 2 Apr 2024 19:33:53 +0000 (16:33 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:31:53 +0000 (14:31 +0200)
commit ca545b7f0823f19db0f1148d59bc5e1a56634502 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_ses_exiting()
  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/cifs_debug.c
fs/cifs/cifsglob.h

index e7501533c2ec9a6d885d54264a59ca84a693ce01..8eb91bd18439b64915a96512c32342c13c719a6c 100644 (file)
@@ -183,6 +183,8 @@ static int cifs_debug_files_proc_show(struct seq_file *m, void *v)
        list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
                list_for_each(tmp, &server->smb_ses_list) {
                        ses = list_entry(tmp, struct cifs_ses, smb_ses_list);
+                       if (cifs_ses_exiting(ses))
+                               continue;
                        list_for_each(tmp1, &ses->tcon_list) {
                                tcon = list_entry(tmp1, struct cifs_tcon, tcon_list);
                                spin_lock(&tcon->open_file_lock);
index 2ee67a27020d9e5abc47a99a5235fa77738a90e5..7b57cc5d702213d19af90dfb5ff8f4d244daeb32 100644 (file)
@@ -2041,4 +2041,12 @@ static inline struct scatterlist *cifs_sg_set_buf(struct scatterlist *sg,
        return sg;
 }
 
+static inline bool cifs_ses_exiting(struct cifs_ses *ses)
+{
+       bool ret;
+
+       ret = ses->status == CifsExiting;
+       return ret;
+}
+
 #endif /* _CIFS_GLOB_H */