public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5.15.y] smb: client: fix potential UAF in cifs_debug_files_proc_show()
@ 2025-03-19  3:01 jianqi.ren.cn
  2025-03-19 10:54 ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: jianqi.ren.cn @ 2025-03-19  3:01 UTC (permalink / raw)
  To: stable
  Cc: patches, gregkh, linux-kernel, jianqi.ren.cn, sfrench, linux-cifs,
	samba-technical, pc, stfrench

From: Paulo Alcantara <pc@manguebit.com>

[ Upstream commit ca545b7f0823f19db0f1148d59bc5e1a56634502 ]

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>
---
Verified the build test
---
 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 e7501533c2ec..8eb91bd18439 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -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);
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 2ee67a27020d..7b57cc5d7022 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -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 */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 5.15.y] smb: client: fix potential UAF in cifs_debug_files_proc_show()
  2025-03-19  3:01 [PATCH 5.15.y] smb: client: fix potential UAF in cifs_debug_files_proc_show() jianqi.ren.cn
@ 2025-03-19 10:54 ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2025-03-19 10:54 UTC (permalink / raw)
  To: stable; +Cc: jianqi.ren.cn, Sasha Levin

[ Sasha's backport helper bot ]

Hi,

The upstream commit SHA1 provided is correct: ca545b7f0823f19db0f1148d59bc5e1a56634502

WARNING: Author mismatch between patch and upstream commit:
Backport author: <jianqi.ren.cn@windriver.com>
Commit author: Paulo Alcantara<pc@manguebit.com>

Status in newer kernel trees:
6.13.y | Present (exact SHA1)
6.12.y | Present (exact SHA1)
6.6.y | Present (different SHA1: a65f2b56334b)
6.1.y | Present (different SHA1: 229042314602)

Note: The patch differs from the upstream commit:
---
1:  ca545b7f0823f < -:  ------------- smb: client: fix potential UAF in cifs_debug_files_proc_show()
-:  ------------- > 1:  374668b862d38 smb: client: fix potential UAF in cifs_debug_files_proc_show()
---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-5.15.y       |  Success    |  Success   |

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-03-19 10:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-19  3:01 [PATCH 5.15.y] smb: client: fix potential UAF in cifs_debug_files_proc_show() jianqi.ren.cn
2025-03-19 10:54 ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox