CIFS: Fix NULL pointer deref on TCON failures
Subsystems (3)
PATCH 1/1 CIFS: Fix NULL pointer deref on TCON failures
--- fs/cifs/smb2pdu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/cifs/smb2pdu.c +3 -1
@@ -1255,7 +1255,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,struct smb2_tree_connect_req *req;struct smb2_tree_connect_rsp *rsp =NULL ;struct kvec iov[2 ]; -struct kvec rsp_iov; +struct kvec rsp_iov = {NULL ,0 };int rc =0 ;int resp_buftype;int unc_path_len;
@@ -1315,6 +1315,8 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, rc =SendReceive2 (xid, ses, iov,2 , &resp_buftype, flags, &rsp_iov);cifs_small_buf_release (req); rsp = (struct smb2_tree_connect_rsp *)rsp_iov.iov_base; +if (rsp ==NULL ) + goto tcon_exit;if (rc !=0 ) {if (tcon) {
Signature · 1 line
2.13.3
A message that is not in the archive (sent off-list or not yet received): 20171010230138.31832-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
probably should cc stable ...
Quoted 30 lines · Ronnie Sahlberg
Signed-off-by Ronnie Sahlberg <[email protected]>--- fs/cifs/smb2pdu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)fs/cifs/smb2pdu.c +3
-2@@ -1255,7 +1255,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,struct smb2_tree_connect_req *req;struct smb2_tree_connect_rsp *rsp =NULL ;struct kvec iov[2 ]; -struct kvec rsp_iov; +struct kvec rsp_iov = {NULL ,0 };int rc =0 ;int resp_buftype;int unc_path_len;@@ -1315,6 +1315,8 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, rc =SendReceive2 (xid, ses, iov,2 , &resp_buftype, flags, &rsp_iov);cifs_small_buf_release (req); rsp = (struct smb2_tree_connect_rsp *)rsp_iov.iov_base; +if (rsp ==NULL ) + goto tcon_exit;if (rc !=0 ) {if (tcon) { --2.13.3
Signature · 3 lines
Thanks, Steve
Wah! I believe we worked on the exact same bug. I was just about to send a similar patch (coming up).
The difference is the code still goes thru the block that sets the reconnect flag, which we should do I think.
Quoted 9 lines
rsp = (struct smb2_tree_connect_rsp *)rsp_iov.iov_base;
if (rc != 0) {
if (tcon) {
cifs_stats_fail_inc(tcon, SMB2_TREE_CONNECT_HE);
tcon->need_reconnect = true;
}
goto tcon_error_exit;
}this block ^^^^^
Signature · 4 lines
Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
Steve French
Appliedmerged into cifs-2.6.git for-next and cc: stable
Quoted 30 lines · Ronnie Sahlberg
Signed-off-by Ronnie Sahlberg <[email protected]>--- fs/cifs/smb2pdu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)fs/cifs/smb2pdu.c +3
-2@@ -1255,7 +1255,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,struct smb2_tree_connect_req *req;struct smb2_tree_connect_rsp *rsp =NULL ;struct kvec iov[2 ]; -struct kvec rsp_iov; +struct kvec rsp_iov = {NULL ,0 };int rc =0 ;int resp_buftype;int unc_path_len;@@ -1315,6 +1315,8 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, rc =SendReceive2 (xid, ses, iov,2 , &resp_buftype, flags, &rsp_iov);cifs_small_buf_release (req); rsp = (struct smb2_tree_connect_rsp *)rsp_iov.iov_base; +if (rsp ==NULL ) + goto tcon_exit;if (rc !=0 ) {if (tcon) { --2.13.3
Signature · 3 lines
Thanks, Steve
PATCH 1/1 CIFS: Fix NULL pointer deref on SMB2_tcon() failure
In reply to Ronnie SahlbergIf SendReceive2() fails rsp is set to NULL but is dereferenced in the error handling code.
--- fs/cifs/smb2pdu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/cifs/smb2pdu.c +2 -2
@@ -1168,7 +1168,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,struct smb2_tree_connect_req *req;struct smb2_tree_connect_rsp *rsp =NULL ;struct kvec iov[2 ]; -struct kvec rsp_iov; +struct kvec rsp_iov = {NULL ,0 };int rc =0 ;int resp_buftype;int unc_path_len;
@@ -1285,7 +1285,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,return rc; tcon_error_exit: -if (rsp->hdr.sync_hdr.Status ==STATUS_BAD_NETWORK_NAME ) { +if (rsp && rsp->hdr.sync_hdr.Status ==STATUS_BAD_NETWORK_NAME ) {cifs_dbg (VFS ,"BAD_NETWORK_NAME: %s\n" , tree); } goto tcon_exit;
Signature · 1 line
2.12.3
A message that is not in the archive (sent off-list or not yet received): 20171011112336.11263-1-aaptel-IBi9RG/[email protected]
Pavel Shilovsky
Reviewed-byRe: [PATCH] CIFS: Fix NULL pointer deref on SMB2_tcon() failure
2017-10-11 4:23 GMT-07:00 Aurelien Aptel <aaptel-IBi9RG/[email protected]>:
Quoted 34 lines
If
SendReceive2()fails rsp is set to NULL but is dereferenced in the error handling code.Signed-off-by Aurelien Aptel <aaptel-IBi9RG/[email protected]>--- fs/cifs/smb2pdu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/cifs/smb2pdu.c +2
-3@@ -1168,7 +1168,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,struct smb2_tree_connect_req *req;struct smb2_tree_connect_rsp *rsp =NULL ;struct kvec iov[2 ]; -struct kvec rsp_iov; +struct kvec rsp_iov = {NULL ,0 };int rc =0 ;int resp_buftype;int unc_path_len;@@ -1285,7 +1285,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,return rc; tcon_error_exit: -if (rsp->hdr.sync_hdr.Status ==STATUS_BAD_NETWORK_NAME ) { +if (rsp && rsp->hdr.sync_hdr.Status ==STATUS_BAD_NETWORK_NAME ) {cifs_dbg (VFS ,"BAD_NETWORK_NAME: %s\n" , tree); } goto tcon_exit; --2.12.3
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Good catch, Ronnie, Aurelien!
It seems like the issue exists even before SendReceive2() refactoring but wasn't triggered until DFS support was added.
--
Best regards,
Pavel Shilovsky