Skip to content

Commit 83912d6

Browse files
socram8888smfrench
authored andcommitted
ksmbd: disable SMB2_GLOBAL_CAP_ENCRYPTION for SMB 3.1.1
According to the official Microsoft MS-SMB2 document section 3.3.5.4, this flag should be used only for 3.0 and 3.0.2 dialects. Setting it for 3.1.1 is a violation of the specification. This causes my Windows 10 client to detect an anomaly in the negotiation, and disable encryption entirely despite being explicitly enabled in ksmbd, causing all data transfers to go in plain text. Fixes: e2f3448 ("cifsd: add server-side procedures for SMB3") Cc: stable@vger.kernel.org # v5.15 Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Marcos Del Sol Vives <marcos@orca.pet> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent f2e78af commit 83912d6

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

fs/ksmbd/smb2ops.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,6 @@ int init_smb3_11_server(struct ksmbd_conn *conn)
271271
if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB2_LEASES)
272272
conn->vals->capabilities |= SMB2_GLOBAL_CAP_LEASING;
273273

274-
if (conn->cipher_type)
275-
conn->vals->capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
276-
277274
if (server_conf.flags & KSMBD_GLOBAL_FLAG_SMB3_MULTICHANNEL)
278275
conn->vals->capabilities |= SMB2_GLOBAL_CAP_MULTI_CHANNEL;
279276

fs/ksmbd/smb2pdu.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,25 @@ static void decode_encrypt_ctxt(struct ksmbd_conn *conn,
915915
}
916916
}
917917

918+
/**
919+
* smb3_encryption_negotiated() - checks if server and client agreed on enabling encryption
920+
* @conn: smb connection
921+
*
922+
* Return: true if connection should be encrypted, else false
923+
*/
924+
static bool smb3_encryption_negotiated(struct ksmbd_conn *conn)
925+
{
926+
if (!conn->ops->generate_encryptionkey)
927+
return false;
928+
929+
/*
930+
* SMB 3.0 and 3.0.2 dialects use the SMB2_GLOBAL_CAP_ENCRYPTION flag.
931+
* SMB 3.1.1 uses the cipher_type field.
932+
*/
933+
return (conn->vals->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION) ||
934+
conn->cipher_type;
935+
}
936+
918937
static void decode_compress_ctxt(struct ksmbd_conn *conn,
919938
struct smb2_compression_capabilities_context *pneg_ctxt)
920939
{
@@ -1469,8 +1488,7 @@ static int ntlm_authenticate(struct ksmbd_work *work)
14691488
(req->SecurityMode & SMB2_NEGOTIATE_SIGNING_REQUIRED))
14701489
sess->sign = true;
14711490

1472-
if (conn->vals->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION &&
1473-
conn->ops->generate_encryptionkey &&
1491+
if (smb3_encryption_negotiated(conn) &&
14741492
!(req->Flags & SMB2_SESSION_REQ_FLAG_BINDING)) {
14751493
rc = conn->ops->generate_encryptionkey(sess);
14761494
if (rc) {
@@ -1559,8 +1577,7 @@ static int krb5_authenticate(struct ksmbd_work *work)
15591577
(req->SecurityMode & SMB2_NEGOTIATE_SIGNING_REQUIRED))
15601578
sess->sign = true;
15611579

1562-
if ((conn->vals->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION) &&
1563-
conn->ops->generate_encryptionkey) {
1580+
if (smb3_encryption_negotiated(conn)) {
15641581
retval = conn->ops->generate_encryptionkey(sess);
15651582
if (retval) {
15661583
ksmbd_debug(SMB,

0 commit comments

Comments
 (0)