@@ -79,9 +79,14 @@ static const int smb2_req_struct_sizes[NUMBER_OF_SMB2_COMMANDS] = {
7979
8080static int encryption_required (const struct cifs_tcon * tcon )
8181{
82+ if (!tcon )
83+ return 0 ;
8284 if ((tcon -> ses -> session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA ) ||
8385 (tcon -> share_flags & SHI1005_FLAGS_ENCRYPT_DATA ))
8486 return 1 ;
87+ if (tcon -> seal &&
88+ (tcon -> ses -> server -> capabilities & SMB2_GLOBAL_CAP_ENCRYPTION ))
89+ return 1 ;
8590 return 0 ;
8691}
8792
@@ -835,8 +840,6 @@ SMB2_auth_kerberos(struct SMB2_sess_data *sess_data)
835840 ses -> Suid = rsp -> hdr .sync_hdr .SessionId ;
836841
837842 ses -> session_flags = le16_to_cpu (rsp -> SessionFlags );
838- if (ses -> session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA )
839- cifs_dbg (VFS , "SMB3 encryption not supported yet\n" );
840843
841844 rc = SMB2_sess_establish_session (sess_data );
842845out_put_spnego_key :
@@ -933,8 +936,6 @@ SMB2_sess_auth_rawntlmssp_negotiate(struct SMB2_sess_data *sess_data)
933936
934937 ses -> Suid = rsp -> hdr .sync_hdr .SessionId ;
935938 ses -> session_flags = le16_to_cpu (rsp -> SessionFlags );
936- if (ses -> session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA )
937- cifs_dbg (VFS , "SMB3 encryption not supported yet\n" );
938939
939940out :
940941 kfree (ntlmssp_blob );
@@ -993,8 +994,6 @@ SMB2_sess_auth_rawntlmssp_authenticate(struct SMB2_sess_data *sess_data)
993994
994995 ses -> Suid = rsp -> hdr .sync_hdr .SessionId ;
995996 ses -> session_flags = le16_to_cpu (rsp -> SessionFlags );
996- if (ses -> session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA )
997- cifs_dbg (VFS , "SMB3 encryption not supported yet\n" );
998997
999998 rc = SMB2_sess_establish_session (sess_data );
1000999out :
@@ -1145,12 +1144,6 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
11451144 if (tcon && tcon -> bad_network_name )
11461145 return - ENOENT ;
11471146
1148- if ((tcon && tcon -> seal ) &&
1149- ((ses -> server -> capabilities & SMB2_GLOBAL_CAP_ENCRYPTION ) == 0 )) {
1150- cifs_dbg (VFS , "encryption requested but no server support" );
1151- return - EOPNOTSUPP ;
1152- }
1153-
11541147 unc_path = kmalloc (MAX_SHARENAME_LENGTH * 2 , GFP_KERNEL );
11551148 if (unc_path == NULL )
11561149 return - ENOMEM ;
@@ -1168,15 +1161,16 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
11681161 return rc ;
11691162 }
11701163
1171- if (ses -> session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA )
1172- flags |= CIFS_TRANSFORM_REQ ;
1173-
11741164 if (tcon == NULL ) {
1165+ if ((ses -> session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA ))
1166+ flags |= CIFS_TRANSFORM_REQ ;
1167+
11751168 /* since no tcon, smb2_init can not do this, so do here */
11761169 req -> hdr .sync_hdr .SessionId = ses -> Suid ;
11771170 /* if (ses->server->sec_mode & SECMODE_SIGN_REQUIRED)
11781171 req->hdr.Flags |= SMB2_FLAGS_SIGNED; */
1179- }
1172+ } else if (encryption_required (tcon ))
1173+ flags |= CIFS_TRANSFORM_REQ ;
11801174
11811175 iov [0 ].iov_base = (char * )req ;
11821176 /* 4 for rfc1002 length field and 1 for pad */
@@ -1233,9 +1227,12 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
12331227 if ((rsp -> Capabilities & SMB2_SHARE_CAP_DFS ) &&
12341228 ((tcon -> share_flags & SHI1005_FLAGS_DFS ) == 0 ))
12351229 cifs_dbg (VFS , "DFS capability contradicts DFS flag\n" );
1230+
1231+ if (tcon -> seal &&
1232+ !(tcon -> ses -> server -> capabilities & SMB2_GLOBAL_CAP_ENCRYPTION ))
1233+ cifs_dbg (VFS , "Encryption is requested but not supported\n" );
1234+
12361235 init_copy_chunk_defaults (tcon );
1237- if (tcon -> share_flags & SHI1005_FLAGS_ENCRYPT_DATA )
1238- cifs_dbg (VFS , "Encrypted shares not supported" );
12391236 if (tcon -> ses -> server -> ops -> validate_negotiate )
12401237 rc = tcon -> ses -> server -> ops -> validate_negotiate (xid , tcon );
12411238tcon_exit :
0 commit comments