This is a note to let you know that I've just added the patch titled smb: client: fix potential UAF in cifs_debug_files_proc_show() to the 6.6-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: smb-client-fix-potential-uaf-in-cifs_debug_files_proc_show.patch and it can be found in the queue-6.6 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From ca545b7f0823f19db0f1148d59bc5e1a56634502 Mon Sep 17 00:00:00 2001 From: Paulo Alcantara <pc@xxxxxxxxxxxxx> Date: Tue, 2 Apr 2024 16:33:53 -0300 Subject: smb: client: fix potential UAF in cifs_debug_files_proc_show() From: Paulo Alcantara <pc@xxxxxxxxxxxxx> commit ca545b7f0823f19db0f1148d59bc5e1a56634502 upstream. Skip sessions that are being teared down (status == SES_EXITING) to avoid UAF. Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Paulo Alcantara (Red Hat) <pc@xxxxxxxxxxxxx> Signed-off-by: Steve French <stfrench@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/smb/client/cifs_debug.c | 2 ++ fs/smb/client/cifsglob.h | 10 ++++++++++ 2 files changed, 12 insertions(+) --- 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(st 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) { --- 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 */ Patches currently in stable-queue which might be from pc@xxxxxxxxxxxxx are queue-6.6/smb-client-fix-potential-uaf-in-cifs_stats_proc_write.patch queue-6.6/smb-client-fix-potential-uaf-in-is_valid_oplock_break.patch queue-6.6/smb-client-serialise-cifs_construct_tcon-with-cifs_mount_mutex.patch queue-6.6/smb-client-fix-potential-uaf-in-cifs_dump_full_key.patch queue-6.6/smb-client-fix-potential-uaf-in-smb2_is_network_name_deleted.patch queue-6.6/smb-client-fix-potential-uaf-in-cifs_debug_files_proc_show.patch queue-6.6/smb-client-handle-dfs-tcons-in-cifs_construct_tcon.patch queue-6.6/smb-client-fix-potential-uaf-in-smb2_is_valid_lease_break.patch queue-6.6/smb-client-fix-potential-uaf-in-cifs_signal_cifsd_for_reconnect.patch queue-6.6/smb-client-fix-potential-uaf-in-cifs_stats_proc_show.patch queue-6.6/smb-client-fix-potential-uaf-in-smb2_is_valid_oplock_break.patch