[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250811094639.37446-2-chanho.min@lge.com>
Date: Mon, 11 Aug 2025 18:46:36 +0900
From: Chanho Min <chanho.min@....com>
To: Steve French <sfrench@...ba.org>,
linux-cifs@...r.kernel.org
Cc: samba-technical@...ts.samba.org,
linux-kernel@...r.kernel.org,
gunho.lee@....com,
gregkh@...uxfoundation.org,
sashal@...nel.org,
Paulo Alcantara <pc@...guebit.com>,
stable@...r.kernel.org,
Steve French <stfrench@...rosoft.com>,
Jianqi Ren <jianqi.ren.cn@...driver.com>,
He Zhe <zhe.he@...driver.com>,
Chanho Min <chanho.min@....com>
Subject: [PATCH 1/4] smb: client: fix potential UAF in cifs_debug_files_proc_show()
From: Paulo Alcantara <pc@...guebit.com>
commit ca545b7f0823f19db0f1148d59bc5e1a56634502 upstream.
Skip sessions that are being teared down (status == SES_EXITING) to
avoid UAF.
Cc: stable@...r.kernel.org # 5.4
Signed-off-by: Paulo Alcantara (Red Hat) <pc@...guebit.com>
Signed-off-by: Steve French <stfrench@...rosoft.com>
[ This patch removes lock/unlock operation in routine cifs_ses_exiting()
for ses_lock is not present in v5.10 and not ported yet. ses->status
is protected by a global lock, cifs_tcp_ses_lock, in v5.10. ]
Signed-off-by: Jianqi Ren <jianqi.ren.cn@...driver.com>
Signed-off-by: He Zhe <zhe.he@...driver.com>
[ chanho: Backport to v5.4.y from v5.10.y's commit 8f8718afd44 ]
Signed-off-by: Chanho Min <chanho.min@....com>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
---
fs/cifs/cifs_debug.c | 2 ++
fs/cifs/cifsglob.h | 8 ++++++++
2 files changed, 10 insertions(+)
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index efb2928ff6c89..df3dfa611c352 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -162,6 +162,8 @@ static int cifs_debug_files_proc_show(struct seq_file *m, void *v)
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);
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 253321adc2664..5f545a240afa6 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -2027,4 +2027,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 */
Powered by blists - more mailing lists