kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cifs: fix NULL dereference in smb2_check_message()
@ 2021-06-22 10:59 Dan Carpenter
  2021-06-23 11:29 ` Aurélien Aptel
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-06-22 10:59 UTC (permalink / raw)
  To: Steve French; +Cc: Baokun Li, linux-cifs, samba-technical, kernel-janitors

This code sets "ses" to NULL which will lead to a NULL dereference on
the second iteration through the loop.

Fixes: 85346c17e425 ("cifs: convert list_for_each to entry variant in smb2misc.c")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 fs/cifs/smb2misc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
index c6bb2ea1983b..668f77108831 100644
--- a/fs/cifs/smb2misc.c
+++ b/fs/cifs/smb2misc.c
@@ -158,11 +158,10 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr)
 		list_for_each_entry(ses, &srvr->smb_ses_list, smb_ses_list) {
 			if (ses->Suid == thdr->SessionId)
 				break;
-
-			ses = NULL;
 		}
 		spin_unlock(&cifs_tcp_ses_lock);
-		if (ses == NULL) {
+		if (list_entry_is_head(ses, &srvr->smb_ses_list,
+				       smb_ses_list)) {
 			cifs_dbg(VFS, "no decryption - session id not found\n");
 			return 1;
 		}
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] cifs: fix NULL dereference in smb2_check_message()
  2021-06-22 10:59 [PATCH] cifs: fix NULL dereference in smb2_check_message() Dan Carpenter
@ 2021-06-23 11:29 ` Aurélien Aptel
  0 siblings, 0 replies; 2+ messages in thread
From: Aurélien Aptel @ 2021-06-23 11:29 UTC (permalink / raw)
  To: Dan Carpenter, Steve French
  Cc: Baokun Li, linux-cifs, samba-technical, kernel-janitors


Reviewed-by: Aurelien Aptel <aaptel@suse.com>

-- 
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-23 11:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22 10:59 [PATCH] cifs: fix NULL dereference in smb2_check_message() Dan Carpenter
2021-06-23 11:29 ` Aurélien Aptel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).