Skip to contentSkip to conversation

ksmbd: Fix read on the uninitialized pointer sess

PATCH In review Colin King 2 participants 2 messages Jul 6, 2021

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 ksmbd: Fix read on the uninitialized pointer sess

From: Colin Ian King <[email protected]>

There is a error handling case that passes control to label out_err without pointer sess being assigned a value. The unassigned pointer may be any garbage value and so the test of rc < 0 && sess maybe true leading to sess being passed to the call to ksmbd_session_destroy. Fix this by setting sess to NULL in this corner case.

Addresses-Coverity: ("Uninitialized pointer read")

Fixes f5a544e3bab7 ("ksmbd: add support for SMB3 multichannel")
---
 fs/ksmbd/smb2pdu.c | 1 +
 1 file changed, 1 insertion(+)
fs/ksmbd/smb2pdu.c +1 -0
index dda90812feef..ad976dbbb0b6 100644
@@ -1615,6 +1615,7 @@ int smb2_sess_setup(struct ksmbd_work *work)
 	} else if ((conn->dialect < SMB30_PROT_ID ||
 		    server_conf.flags & KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL) &&
 		   (req->Flags & SMB2_SESSION_REQ_FLAG_BINDING)) {
+		sess = NULL;
 		rc = -EACCES;
 		goto out_err;
 	} else {
Signature · 1 line
2.31.1
maintainer
#1 lore raw

Hi Colin,

2021-07-06 21:05 GMT+09:00, Colin King <[email protected]>:

Quoted 11 lines

From: Colin Ian King <[email protected]>

There is a error handling case that passes control to label out_err without pointer sess being assigned a value. The unassigned pointer may be any garbage value and so the test of rc < 0 && sess maybe true leading to sess being passed to the call to ksmbd_session_destroy. Fix this by setting sess to NULL in this corner case.

Addresses-Coverity: ("Uninitialized pointer read")

Fixes f5a544e3bab7 ("ksmbd: add support for SMB3 multichannel")

I will apply this patch. Thanks for your patch!