Skip to content

Commit 532b4c8

Browse files
Paulo AlcantaraSasha Levin
authored andcommitted
smb: client: fix potential UAF in cifs_debug_files_proc_show()
commit ca545b7 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>
1 parent c6b363f commit 532b4c8

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

fs/cifs/cifs_debug.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ static int cifs_debug_files_proc_show(struct seq_file *m, void *v)
183183
list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
184184
list_for_each(tmp, &server->smb_ses_list) {
185185
ses = list_entry(tmp, struct cifs_ses, smb_ses_list);
186+
if (cifs_ses_exiting(ses))
187+
continue;
186188
list_for_each(tmp1, &ses->tcon_list) {
187189
tcon = list_entry(tmp1, struct cifs_tcon, tcon_list);
188190
spin_lock(&tcon->open_file_lock);

fs/cifs/cifsglob.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,4 +2041,12 @@ static inline struct scatterlist *cifs_sg_set_buf(struct scatterlist *sg,
20412041
return sg;
20422042
}
20432043

2044+
static inline bool cifs_ses_exiting(struct cifs_ses *ses)
2045+
{
2046+
bool ret;
2047+
2048+
ret = ses->status == CifsExiting;
2049+
return ret;
2050+
}
2051+
20442052
#endif /* _CIFS_GLOB_H */

0 commit comments

Comments
 (0)