Skip to content

Commit 89381c7

Browse files
paliSteve French
authored andcommitted
cifs: Correctly set SMB1 SessionKey field in Session Setup Request
[MS-CIFS] specification in section 2.2.4.53.1 where is described SMB_COM_SESSION_SETUP_ANDX Request, for SessionKey field says: The client MUST set this field to be equal to the SessionKey field in the SMB_COM_NEGOTIATE Response for this SMB connection. Linux SMB client currently set this field to zero. This is working fine against Windows NT SMB servers thanks to [MS-CIFS] product behavior <94>: Windows NT Server ignores the client's SessionKey. For compatibility with [MS-CIFS], set this SessionKey field in Session Setup Request to value retrieved from Negotiate response. Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 6510ef4 commit 89381c7

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

fs/smb/client/cifsglob.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ struct TCP_Server_Info {
773773
char workstation_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL];
774774
__u32 sequence_number; /* for signing, protected by srv_mutex */
775775
__u32 reconnect_instance; /* incremented on each reconnect */
776+
__le32 session_key_id; /* retrieved from negotiate response and send in session setup request */
776777
struct session_key session_key;
777778
unsigned long lstrp; /* when we got last response from this server */
778779
struct cifs_secmech secmech; /* crypto sec mech functs, descriptors */

fs/smb/client/cifspdu.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ typedef union smb_com_session_setup_andx {
597597
__le16 MaxBufferSize;
598598
__le16 MaxMpxCount;
599599
__le16 VcNumber;
600-
__u32 SessionKey;
600+
__le32 SessionKey;
601601
__le16 SecurityBlobLength;
602602
__u32 Reserved;
603603
__le32 Capabilities; /* see below */
@@ -616,7 +616,7 @@ typedef union smb_com_session_setup_andx {
616616
__le16 MaxBufferSize;
617617
__le16 MaxMpxCount;
618618
__le16 VcNumber;
619-
__u32 SessionKey;
619+
__le32 SessionKey;
620620
__le16 CaseInsensitivePasswordLength; /* ASCII password len */
621621
__le16 CaseSensitivePasswordLength; /* Unicode password length*/
622622
__u32 Reserved; /* see below */
@@ -654,7 +654,7 @@ typedef union smb_com_session_setup_andx {
654654
__le16 MaxBufferSize;
655655
__le16 MaxMpxCount;
656656
__le16 VcNumber;
657-
__u32 SessionKey;
657+
__le32 SessionKey;
658658
__le16 PasswordLength;
659659
__u32 Reserved; /* encrypt key len and offset */
660660
__le16 ByteCount;

fs/smb/client/cifssmb.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ CIFSSMBNegotiate(const unsigned int xid,
498498
server->max_rw = le32_to_cpu(pSMBr->MaxRawSize);
499499
cifs_dbg(NOISY, "Max buf = %d\n", ses->server->maxBuf);
500500
server->capabilities = le32_to_cpu(pSMBr->Capabilities);
501+
server->session_key_id = pSMBr->SessionKey;
501502
server->timeAdj = (int)(__s16)le16_to_cpu(pSMBr->ServerTimeZone);
502503
server->timeAdj *= 60;
503504

fs/smb/client/sess.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ static __u32 cifs_ssetup_hdr(struct cifs_ses *ses,
628628
USHRT_MAX));
629629
pSMB->req.MaxMpxCount = cpu_to_le16(server->maxReq);
630630
pSMB->req.VcNumber = cpu_to_le16(1);
631+
pSMB->req.SessionKey = server->session_key_id;
631632

632633
/* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */
633634

0 commit comments

Comments
 (0)