SMB: fix validate negotiate info uninitialised memory use
authorDavid Disseldorp <ddiss@suse.de>
Fri, 20 Oct 2017 12:49:38 +0000 (14:49 +0200)
committerSteve French <smfrench@gmail.com>
Wed, 25 Oct 2017 18:04:25 +0000 (13:04 -0500)
An undersize validate negotiate info server response causes the client
to use uninitialised memory for struct validate_negotiate_info_rsp
comparisons of Dialect, SecurityMode and/or Capabilities members.

Link: https://bugzilla.samba.org/show_bug.cgi?id=13092
Fixes: 7db0a6efdc3e ("SMB3: Work around mount failure when using SMB3 dialect to Macs")
Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/smb2pdu.c

index 6b03e2d..ba58af7 100644 (file)
@@ -727,7 +727,8 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
                         rsplen);
 
                /* relax check since Mac returns max bufsize allowed on ioctl */
-               if (rsplen > CIFSMaxBufSize)
+               if ((rsplen > CIFSMaxBufSize)
+                    || (rsplen < sizeof(struct validate_negotiate_info_rsp)))
                        goto err_rsp_free;
        }