Skip to contentSkip to conversation

smb2: fix uninitialized variable bug in smb2_ioctl_query_info

PATCH Superseded Gustavo A. R. Silva 2 participants 3 messages Oct 9, 2018

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 smb2: fix uninitialized variable bug in smb2_ioctl_query_info

There is a potential execution path in which variable *resp_buftype* is passed as an argument to function free_rsp_buf(), in which it is used in a comparison without being properly initialized previously.

Fix this by initializing variable *resp_buftype* to -1 in order to avoid unpredictable or unintended results.

Addresses-Coverity-ID: 1473971 ("Uninitialized scalar variable")

Fixes c5d25bdb2967 ("cifs: add IOCTL for QUERY_INFO passthrough to userspace")

---
Changes in v2:
- Fix Coverity and Fixes tag.
- Update commit log.

 fs/cifs/smb2ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/smb2ops.c +1 -1
index c6c6450d..927aadd 100644
@@ -1133,7 +1133,7 @@ smb2_ioctl_query_info(const unsigned int xid,
 	struct smb_rqst rqst;
 	struct kvec iov[1];
 	struct kvec rsp_iov;
-	int resp_buftype;
+	int resp_buftype = -1;
 	struct smb2_query_info_rsp *rsp = NULL;
 	void *buffer;
 
Signature · 1 line
2.7.4
#1 lore raw

Good catch, but I think it should be :

int resp_buftype = CIFS_NO_BUFFER;

----- Original Message -----
From: "Gustavo A. R. Silva" <[email protected]>
To: "Steve French" <[email protected]>, "Ronnie Sahlberg" <[email protected]>
Cc: [email protected], [email protected], [email protected], "Gustavo A. R. Silva" <[email protected]>
Sent: Wednesday, 10 October, 2018 6:17:48 AM
Subject: [PATCH v2] smb2: fix uninitialized variable bug in smb2_ioctl_query_info

There is a potential execution path in which variable *resp_buftype* is passed as an argument to function free_rsp_buf(), in which it is used in a comparison without being properly initialized previously.

Fix this by initializing variable *resp_buftype* to -1 in order to avoid unpredictable or unintended results.

Addresses-Coverity-ID: 1473971 ("Uninitialized scalar variable")

Fixes c5d25bdb2967 ("cifs: add IOCTL for QUERY_INFO passthrough to userspace")

---
Changes in v2:
- Fix Coverity and Fixes tag.
- Update commit log.

 fs/cifs/smb2ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/smb2ops.c +1 -1
index c6c6450d..927aadd 100644
@@ -1133,7 +1133,7 @@ smb2_ioctl_query_info(const unsigned int xid,
 	struct smb_rqst rqst;
 	struct kvec iov[1];
 	struct kvec rsp_iov;
-	int resp_buftype;
+	int resp_buftype = -1;
 	struct smb2_query_info_rsp *rsp = NULL;
 	void *buffer;
 
Signature · 1 line
2.7.4
#2 lore raw

Hey Ronnie,

Quoted 4 lines · Ronnie Sahlberg

Good catch, but I think it should be :

int resp_buftype = CIFS_NO_BUFFER;

Oh okay. I'll send v3 shortly.

Thanks for the feedback.
--
Gustavo