[PATCH 3/4] smb: client: fix potential UAF in smb2_is_valid_lease_break()
From: Chanho Min
Date: Mon Aug 11 2025 - 06:17:31 EST
From: Paulo Alcantara <pc@xxxxxxxxxxxxx>
Skip sessions that are being teared down (status == SES_EXITING) to
avoid UAF.
Cc: stable@xxxxxxxxxxxxxxx # 5.4
Signed-off-by: Paulo Alcantara (Red Hat) <pc@xxxxxxxxxxxxx>
[ chanho: Backported to v5.4.y, smb2misc.c was moved from fs/cifs to fs/smb/client ]
Signed-off-by: Chanho Min <chanho.min@xxxxxxx>
Signed-off-by: Steve French <stfrench@xxxxxxxxxxxxx>
---
fs/cifs/smb2misc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
index d7cbf1b07126c..c47927d257635 100644
--- a/fs/cifs/smb2misc.c
+++ b/fs/cifs/smb2misc.c
@@ -611,7 +611,8 @@ smb2_is_valid_lease_break(char *buffer)
list_for_each(tmp1, &server->smb_ses_list) {
ses = list_entry(tmp1, struct cifs_ses, smb_ses_list);
-
+ if (cifs_ses_exiting(ses))
+ continue;
list_for_each(tmp2, &ses->tcon_list) {
tcon = list_entry(tmp2, struct cifs_tcon,
tcon_list);