aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve French <stfrench@microsoft.com>2018-04-22 16:14:58 -0400
committerSteve French <stfrench@microsoft.com>2018-04-24 11:07:14 -0400
commit23657ad7305ee8b263d27335abdd00917764c9cf (patch)
tree2827d1147ef01e88692057e2be8f94d078260cc4
parent117e3b7fed552eba96ae0b3b92312fe8c5b0bfdd (diff)
SMB3: Fix 3.11 encryption to Windows and handle encrypted smb3 tcon
Temporarily disable AES-GCM, as AES-CCM is only currently enabled mechanism on client side. This fixes SMB3.11 encrypted mounts to Windows. Also the tree connect request itself should be encrypted if requested encryption ("seal" on mount), in addition we should be enabling encryption in 3.11 based on whether we got any valid encryption ciphers back in negprot (the corresponding session flag is not set as it is in 3.0 and 3.02) Signed-off-by: Steve French <smfrench@gmail.com> Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com> Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com> CC: Stable <stable@vger.kernel.org>
-rw-r--r--fs/cifs/connect.c32
-rw-r--r--fs/cifs/smb2pdu.c9
-rw-r--r--fs/cifs/smb2pdu.h2
3 files changed, 22 insertions, 21 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index e8830f076a7f..a5aa158d535a 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2959,6 +2959,22 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
2959 } 2959 }
2960 } 2960 }
2961 2961
2962 if (volume_info->seal) {
2963 if (ses->server->vals->protocol_id == 0) {
2964 cifs_dbg(VFS,
2965 "SMB3 or later required for encryption\n");
2966 rc = -EOPNOTSUPP;
2967 goto out_fail;
2968 } else if (tcon->ses->server->capabilities &
2969 SMB2_GLOBAL_CAP_ENCRYPTION)
2970 tcon->seal = true;
2971 else {
2972 cifs_dbg(VFS, "Encryption is not supported on share\n");
2973 rc = -EOPNOTSUPP;
2974 goto out_fail;
2975 }
2976 }
2977
2962 /* 2978 /*
2963 * BB Do we need to wrap session_mutex around this TCon call and Unix 2979 * BB Do we need to wrap session_mutex around this TCon call and Unix
2964 * SetFS as we do on SessSetup and reconnect? 2980 * SetFS as we do on SessSetup and reconnect?
@@ -3007,22 +3023,6 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
3007 tcon->use_resilient = true; 3023 tcon->use_resilient = true;
3008 } 3024 }
3009 3025
3010 if (volume_info->seal) {
3011 if (ses->server->vals->protocol_id == 0) {
3012 cifs_dbg(VFS,
3013 "SMB3 or later required for encryption\n");
3014 rc = -EOPNOTSUPP;
3015 goto out_fail;
3016 } else if (tcon->ses->server->capabilities &
3017 SMB2_GLOBAL_CAP_ENCRYPTION)
3018 tcon->seal = true;
3019 else {
3020 cifs_dbg(VFS, "Encryption is not supported on share\n");
3021 rc = -EOPNOTSUPP;
3022 goto out_fail;
3023 }
3024 }
3025
3026 /* 3026 /*
3027 * We can have only one retry value for a connection to a share so for 3027 * We can have only one retry value for a connection to a share so for
3028 * resources mounted more than once to the same server share the last 3028 * resources mounted more than once to the same server share the last
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 0f044c4a2dc9..9aea138dd71f 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -383,10 +383,10 @@ static void
383build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt) 383build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt)
384{ 384{
385 pneg_ctxt->ContextType = SMB2_ENCRYPTION_CAPABILITIES; 385 pneg_ctxt->ContextType = SMB2_ENCRYPTION_CAPABILITIES;
386 pneg_ctxt->DataLength = cpu_to_le16(6); 386 pneg_ctxt->DataLength = cpu_to_le16(4); /* Cipher Count + le16 cipher */
387 pneg_ctxt->CipherCount = cpu_to_le16(2); 387 pneg_ctxt->CipherCount = cpu_to_le16(1);
388 pneg_ctxt->Ciphers[0] = SMB2_ENCRYPTION_AES128_GCM; 388/* pneg_ctxt->Ciphers[0] = SMB2_ENCRYPTION_AES128_GCM;*/ /* not supported yet */
389 pneg_ctxt->Ciphers[1] = SMB2_ENCRYPTION_AES128_CCM; 389 pneg_ctxt->Ciphers[0] = SMB2_ENCRYPTION_AES128_CCM;
390} 390}
391 391
392static void 392static void
@@ -444,6 +444,7 @@ static int decode_encrypt_ctx(struct TCP_Server_Info *server,
444 return -EINVAL; 444 return -EINVAL;
445 } 445 }
446 server->cipher_type = ctxt->Ciphers[0]; 446 server->cipher_type = ctxt->Ciphers[0];
447 server->capabilities |= SMB2_GLOBAL_CAP_ENCRYPTION;
447 return 0; 448 return 0;
448} 449}
449 450
diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h
index 6093e5142b2b..d28f358022c5 100644
--- a/fs/cifs/smb2pdu.h
+++ b/fs/cifs/smb2pdu.h
@@ -297,7 +297,7 @@ struct smb2_encryption_neg_context {
297 __le16 DataLength; 297 __le16 DataLength;
298 __le32 Reserved; 298 __le32 Reserved;
299 __le16 CipherCount; /* AES-128-GCM and AES-128-CCM */ 299 __le16 CipherCount; /* AES-128-GCM and AES-128-CCM */
300 __le16 Ciphers[2]; /* Ciphers[0] since only one used now */ 300 __le16 Ciphers[1]; /* Ciphers[0] since only one used now */
301} __packed; 301} __packed;
302 302
303struct smb2_negotiate_rsp { 303struct smb2_negotiate_rsp {