Skip to content

Commit ca545b7

Browse files
Paulo AlcantaraSteve French
authored andcommitted
smb: client: fix potential UAF in cifs_debug_files_proc_show()
Skip sessions that are being teared down (status == SES_EXITING) to avoid UAF. Cc: [email protected] Signed-off-by: Paulo Alcantara (Red Hat) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 173217b commit ca545b7

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

fs/smb/client/cifs_debug.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ static int cifs_debug_files_proc_show(struct seq_file *m, void *v)
250250
spin_lock(&cifs_tcp_ses_lock);
251251
list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
252252
list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
253+
if (cifs_ses_exiting(ses))
254+
continue;
253255
list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
254256
spin_lock(&tcon->open_file_lock);
255257
list_for_each_entry(cfile, &tcon->openFileList, tlist) {

fs/smb/client/cifsglob.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,4 +2325,14 @@ struct smb2_compound_vars {
23252325
struct kvec ea_iov;
23262326
};
23272327

2328+
static inline bool cifs_ses_exiting(struct cifs_ses *ses)
2329+
{
2330+
bool ret;
2331+
2332+
spin_lock(&ses->ses_lock);
2333+
ret = ses->ses_status == SES_EXITING;
2334+
spin_unlock(&ses->ses_lock);
2335+
return ret;
2336+
}
2337+
23282338
#endif /* _CIFS_GLOB_H */

0 commit comments

Comments
 (0)