]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cifs: Correctly set SMB1 SessionKey field in Session Setup Request
authorPali Rohár <pali@kernel.org>
Sat, 2 Nov 2024 16:58:31 +0000 (17:58 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 6 Jul 2025 08:57:53 +0000 (10:57 +0200)
[ Upstream commit 89381c72d52094988e11d23ef24a00066a0fa458 ]

[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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/smb/client/cifsglob.h
fs/smb/client/cifspdu.h
fs/smb/client/cifssmb.c
fs/smb/client/sess.c

index 17fce0afb297f98140e5a93651c98fb7d39c4f3d..9c5aa646b8cc8bf88b321b282a13d2ece0126315 100644 (file)
@@ -675,6 +675,7 @@ struct TCP_Server_Info {
        char workstation_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL];
        __u32 sequence_number; /* for signing, protected by srv_mutex */
        __u32 reconnect_instance; /* incremented on each reconnect */
+       __le32 session_key_id; /* retrieved from negotiate response and send in session setup request */
        struct session_key session_key;
        unsigned long lstrp; /* when we got last response from this server */
        struct cifs_secmech secmech; /* crypto sec mech functs, descriptors */
index 9cb4577063344387c1333ab527eab5962b9a4240..a682c50d7ace437d2f107f5480c9bd69f592dec0 100644 (file)
@@ -557,7 +557,7 @@ typedef union smb_com_session_setup_andx {
                __le16 MaxBufferSize;
                __le16 MaxMpxCount;
                __le16 VcNumber;
-               __u32 SessionKey;
+               __le32 SessionKey;
                __le16 SecurityBlobLength;
                __u32 Reserved;
                __le32 Capabilities;    /* see below */
@@ -576,7 +576,7 @@ typedef union smb_com_session_setup_andx {
                __le16 MaxBufferSize;
                __le16 MaxMpxCount;
                __le16 VcNumber;
-               __u32 SessionKey;
+               __le32 SessionKey;
                __le16 CaseInsensitivePasswordLength; /* ASCII password len */
                __le16 CaseSensitivePasswordLength; /* Unicode password length*/
                __u32 Reserved; /* see below */
@@ -614,7 +614,7 @@ typedef union smb_com_session_setup_andx {
                __le16 MaxBufferSize;
                __le16 MaxMpxCount;
                __le16 VcNumber;
-               __u32 SessionKey;
+               __le32 SessionKey;
                __le16 PasswordLength;
                __u32 Reserved; /* encrypt key len and offset */
                __le16 ByteCount;
index 6077fe1dcc9ce540c62a2aa880ebfe79096d5d0f..0c6ade1968947874d35ba822cf5510e5b9b0fca4 100644 (file)
@@ -469,6 +469,7 @@ CIFSSMBNegotiate(const unsigned int xid,
        server->max_rw = le32_to_cpu(pSMBr->MaxRawSize);
        cifs_dbg(NOISY, "Max buf = %d\n", ses->server->maxBuf);
        server->capabilities = le32_to_cpu(pSMBr->Capabilities);
+       server->session_key_id = pSMBr->SessionKey;
        server->timeAdj = (int)(__s16)le16_to_cpu(pSMBr->ServerTimeZone);
        server->timeAdj *= 60;
 
index c8f7ae0a20064c4370e1dedab4bd8e48ffaa8538..883d1cb1fc8b0c1c4435cfb9fa0b4bc4476b9f7d 100644 (file)
@@ -605,6 +605,7 @@ static __u32 cifs_ssetup_hdr(struct cifs_ses *ses,
                                        USHRT_MAX));
        pSMB->req.MaxMpxCount = cpu_to_le16(server->maxReq);
        pSMB->req.VcNumber = cpu_to_le16(1);
+       pSMB->req.SessionKey = server->session_key_id;
 
        /* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */