s3/smbd: Server responds incorrectly if no SMB protocol chosen
authorTim Beale <timbeale@catalyst.net.nz>
Wed, 26 Sep 2018 21:46:41 +0000 (09:46 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 28 Sep 2018 06:30:22 +0000 (08:30 +0200)
The SMBnegprot response from the server contains the DialectIndex of the
selected protocol from the client's request message. Currently, if no
protocol is selected, the server is responding with a DialectIndex=zero,
which is a valid index (PROTOCOL_CORE by default). The Windows spec, and
historically the code, should return DialectIndex=0xffff if no protocol
is chosen. The following commit changed it recently (presumably
inadvertently), so that it now returns DialectIndex=zero.

06940155f315529c5b5 s3:smbd: Fix size types in reply_negprot()

This results in somewhat confusing error messages on the client side:
ERROR(runtime): uncaught exception - (3221225997, 'The transport
connection has been reset.')

or, when signing is configured as mandatory:
smbXcli_negprot: SMB signing is mandatory and the selected protocol
level (1) doesn't support it.
ERROR(runtime): uncaught exception - (3221225506, '{Access Denied} A
process has requested access to an object but has not been granted those
access rights.')

This patch restores the old behaviour of returning 0xffff.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13621

Pair-Programmed-With: Ralph Boehme <slow@samba.org>
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/smbd/negprot.c

index 27366ea0013aa8ca6080d79972b31ca9ede7e824..2d5edf1282c0ce1edab8339eae4397e400d19fc3 100644 (file)
 #include "auth/gensec/gensec.h"
 #include "../libcli/smb/smb_signing.h"
 
+/*
+ * MS-CIFS, 2.2.4.52.2 SMB_COM_NEGOTIATE Response:
+ * If the server does not support any of the listed dialects, it MUST return a
+ * DialectIndex of 0XFFFF
+ */
+#define NO_PROTOCOL_CHOSEN     0xffff
+
 extern fstring remote_proto;
 
 static void get_challenge(struct smbXsrv_connection *xconn, uint8_t buff[8])
@@ -748,7 +755,7 @@ void reply_negprot(struct smb_request *req)
 
                DBG_NOTICE("No protocol supported !\n");
                reply_outbuf(req, 1, 0);
-               SSVAL(req->outbuf, smb_vwv0, choice);
+               SSVAL(req->outbuf, smb_vwv0, NO_PROTOCOL_CHOSEN);
 
                ok = srv_send_smb(xconn, (char *)req->outbuf,
                                  false, 0, false, NULL);