Skip to content

Commit 7955f10

Browse files
author
Steve French
committed
SMB3.1.1: do not log warning message if server doesn't populate salt
In the negotiate protocol preauth context, the server is not required to populate the salt (although it is done by most servers) so do not warn on mount. We retain the checks (warn) that the preauth context is the minimum size and that the salt does not exceed DataLength of the SMB response. Although we use the defaults in the case that the preauth context response is invalid, these checks may be useful in the future as servers add support for additional mechanisms. CC: Stable <[email protected]> Reviewed-by: Shyam Prasad N <[email protected]> Reviewed-by: Pavel Shilovsky <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 145024e commit 7955f10

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

fs/cifs/smb2pdu.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ build_preauth_ctxt(struct smb2_preauth_neg_context *pneg_ctxt)
427427
pneg_ctxt->ContextType = SMB2_PREAUTH_INTEGRITY_CAPABILITIES;
428428
pneg_ctxt->DataLength = cpu_to_le16(38);
429429
pneg_ctxt->HashAlgorithmCount = cpu_to_le16(1);
430-
pneg_ctxt->SaltLength = cpu_to_le16(SMB311_SALT_SIZE);
431-
get_random_bytes(pneg_ctxt->Salt, SMB311_SALT_SIZE);
430+
pneg_ctxt->SaltLength = cpu_to_le16(SMB311_LINUX_CLIENT_SALT_SIZE);
431+
get_random_bytes(pneg_ctxt->Salt, SMB311_LINUX_CLIENT_SALT_SIZE);
432432
pneg_ctxt->HashAlgorithms = SMB2_PREAUTH_INTEGRITY_SHA512;
433433
}
434434

@@ -566,6 +566,9 @@ static void decode_preauth_context(struct smb2_preauth_neg_context *ctxt)
566566
if (len < MIN_PREAUTH_CTXT_DATA_LEN) {
567567
pr_warn_once("server sent bad preauth context\n");
568568
return;
569+
} else if (len < MIN_PREAUTH_CTXT_DATA_LEN + le16_to_cpu(ctxt->SaltLength)) {
570+
pr_warn_once("server sent invalid SaltLength\n");
571+
return;
569572
}
570573
if (le16_to_cpu(ctxt->HashAlgorithmCount) != 1)
571574
pr_warn_once("Invalid SMB3 hash algorithm count\n");

fs/cifs/smb2pdu.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,20 +333,28 @@ struct smb2_neg_context {
333333
/* Followed by array of data */
334334
} __packed;
335335

336-
#define SMB311_SALT_SIZE 32
336+
#define SMB311_LINUX_CLIENT_SALT_SIZE 32
337337
/* Hash Algorithm Types */
338338
#define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001)
339339
#define SMB2_PREAUTH_HASH_SIZE 64
340340

341-
#define MIN_PREAUTH_CTXT_DATA_LEN (SMB311_SALT_SIZE + 6)
341+
/*
342+
* SaltLength that the server send can be zero, so the only three required
343+
* fields (all __le16) end up six bytes total, so the minimum context data len
344+
* in the response is six bytes which accounts for
345+
*
346+
* HashAlgorithmCount, SaltLength, and 1 HashAlgorithm.
347+
*/
348+
#define MIN_PREAUTH_CTXT_DATA_LEN 6
349+
342350
struct smb2_preauth_neg_context {
343351
__le16 ContextType; /* 1 */
344352
__le16 DataLength;
345353
__le32 Reserved;
346354
__le16 HashAlgorithmCount; /* 1 */
347355
__le16 SaltLength;
348356
__le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */
349-
__u8 Salt[SMB311_SALT_SIZE];
357+
__u8 Salt[SMB311_LINUX_CLIENT_SALT_SIZE];
350358
} __packed;
351359

352360
/* Encryption Algorithms Ciphers */

0 commit comments

Comments
 (0)