Skip to content

Commit 7a55d16

Browse files
aaptelgregkh
authored andcommitted
CIFS: add sha512 secmech
commit 5fcd7f3 upstream. * prepare for SMB3.11 pre-auth integrity * enable sha512 when SMB311 is enabled in Kconfig * add sha512 as a soft dependency Signed-off-by: Aurelien Aptel <[email protected]> Signed-off-by: Steve French <[email protected]> CC: Stable <[email protected]> Reviewed-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0910e28 commit 7a55d16

File tree

6 files changed

+44
-0
lines changed

6 files changed

+44
-0
lines changed

fs/cifs/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ config CIFS_NFSD_EXPORT
190190
config CIFS_SMB311
191191
bool "SMB3.1.1 network file system support (Experimental)"
192192
depends on CIFS
193+
select CRYPTO_SHA512
193194

194195
help
195196
This enables experimental support for the newest, SMB3.1.1, dialect.

fs/cifs/cifsencrypt.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,11 @@ cifs_crypto_secmech_release(struct TCP_Server_Info *server)
829829
server->secmech.md5 = NULL;
830830
}
831831

832+
if (server->secmech.md5) {
833+
crypto_free_shash(server->secmech.sha512);
834+
server->secmech.sha512 = NULL;
835+
}
836+
832837
if (server->secmech.hmacmd5) {
833838
crypto_free_shash(server->secmech.hmacmd5);
834839
server->secmech.hmacmd5 = NULL;
@@ -852,4 +857,6 @@ cifs_crypto_secmech_release(struct TCP_Server_Info *server)
852857
server->secmech.sdeschmacmd5 = NULL;
853858
kfree(server->secmech.sdescmd5);
854859
server->secmech.sdescmd5 = NULL;
860+
kfree(server->secmech.sdescsha512);
861+
server->secmech.sdescsha512 = NULL;
855862
}

fs/cifs/cifsfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,7 @@ MODULE_SOFTDEP("pre: nls");
14761476
MODULE_SOFTDEP("pre: aes");
14771477
MODULE_SOFTDEP("pre: cmac");
14781478
MODULE_SOFTDEP("pre: sha256");
1479+
MODULE_SOFTDEP("pre: sha512");
14791480
MODULE_SOFTDEP("pre: aead2");
14801481
MODULE_SOFTDEP("pre: ccm");
14811482
module_init(init_cifs)

fs/cifs/cifsglob.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,12 @@ struct cifs_secmech {
130130
struct crypto_shash *md5; /* md5 hash function */
131131
struct crypto_shash *hmacsha256; /* hmac-sha256 hash function */
132132
struct crypto_shash *cmacaes; /* block-cipher based MAC function */
133+
struct crypto_shash *sha512; /* sha512 hash function */
133134
struct sdesc *sdeschmacmd5; /* ctxt to generate ntlmv2 hash, CR1 */
134135
struct sdesc *sdescmd5; /* ctxt to generate cifs/smb signature */
135136
struct sdesc *sdeschmacsha256; /* ctxt to generate smb2 signature */
136137
struct sdesc *sdesccmacaes; /* ctxt to generate smb3 signature */
138+
struct sdesc *sdescsha512; /* ctxt to generate smb3.11 signing key */
137139
struct crypto_aead *ccmaesencrypt; /* smb3 encryption aead */
138140
struct crypto_aead *ccmaesdecrypt; /* smb3 decryption aead */
139141
};

fs/cifs/smb2proto.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,7 @@ extern int smb3_validate_negotiate(const unsigned int, struct cifs_tcon *);
203203

204204
extern enum securityEnum smb2_select_sectype(struct TCP_Server_Info *,
205205
enum securityEnum);
206+
#ifdef CONFIG_CIFS_SMB311
207+
extern int smb311_crypto_shash_allocate(struct TCP_Server_Info *server);
208+
#endif
206209
#endif /* _SMB2PROTO_H */

fs/cifs/smb2transport.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,36 @@ smb3_crypto_shash_allocate(struct TCP_Server_Info *server)
7070
return rc;
7171
}
7272

73+
#ifdef CONFIG_CIFS_SMB311
74+
int
75+
smb311_crypto_shash_allocate(struct TCP_Server_Info *server)
76+
{
77+
struct cifs_secmech *p = &server->secmech;
78+
int rc = 0;
79+
80+
rc = cifs_alloc_hash("hmac(sha256)",
81+
&p->hmacsha256,
82+
&p->sdeschmacsha256);
83+
if (rc)
84+
return rc;
85+
86+
rc = cifs_alloc_hash("cmac(aes)", &p->cmacaes, &p->sdesccmacaes);
87+
if (rc)
88+
goto err;
89+
90+
rc = cifs_alloc_hash("sha512", &p->sha512, &p->sdescsha512);
91+
if (rc)
92+
goto err;
93+
94+
return 0;
95+
96+
err:
97+
cifs_free_hash(&p->cmacaes, &p->sdesccmacaes);
98+
cifs_free_hash(&p->hmacsha256, &p->sdeschmacsha256);
99+
return rc;
100+
}
101+
#endif
102+
73103
static struct cifs_ses *
74104
smb2_find_smb_ses_unlocked(struct TCP_Server_Info *server, __u64 ses_id)
75105
{

0 commit comments

Comments
 (0)