summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulo Alcantara <pc@manguebit.com>2024-04-02 16:33:53 -0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-04-10 16:36:04 +0200
commita65f2b56334ba4dc30bd5ee9ce5b2691b973344d (patch)
tree0d0c7579f1dedab895aa9e0fdfd764be6bab83ae
parent6f17163b9339fac92023a1d9bef22128db3b9a4b (diff)
downloadlinux-stable-a65f2b56334ba4dc30bd5ee9ce5b2691b973344d.tar.gz
linux-stable-a65f2b56334ba4dc30bd5ee9ce5b2691b973344d.tar.bz2
linux-stable-a65f2b56334ba4dc30bd5ee9ce5b2691b973344d.zip
smb: client: fix potential UAF in cifs_debug_files_proc_show()
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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/smb/client/cifs_debug.c2
-rw-r--r--fs/smb/client/cifsglob.h10
2 files changed, 12 insertions, 0 deletions
diff --git a/fs/smb/client/cifs_debug.c b/fs/smb/client/cifs_debug.c
index 7206167f4184..82cac8169602 100644
--- a/fs/smb/client/cifs_debug.c
+++ b/fs/smb/client/cifs_debug.c
@@ -250,6 +250,8 @@ static int cifs_debug_files_proc_show(struct seq_file *m, void *v)
spin_lock(&cifs_tcp_ses_lock);
list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
list_for_each_entry(ses, &server->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);
list_for_each_entry(cfile, &tcon->openFileList, tlist) {
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index b99767c8d373..a878b1e5aa31 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -2281,4 +2281,14 @@ struct smb2_compound_vars {
struct smb2_file_link_info link_info;
};
+static inline bool cifs_ses_exiting(struct cifs_ses *ses)
+{
+ bool ret;
+
+ spin_lock(&ses->ses_lock);
+ ret = ses->ses_status == SES_EXITING;
+ spin_unlock(&ses->ses_lock);
+ return ret;
+}
+
#endif /* _CIFS_GLOB_H */