Skip to content

Commit 26bc83b

Browse files
Eric Biggerssmfrench
authored andcommitted
smb: client: Compare MACs in constant time
To prevent timing attacks, MAC comparisons need to be constant-time. Replace the memcmp() with the correct function, crypto_memneq(). Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Acked-by: Paulo Alcantara (Red Hat) <pc@manguebit.org> Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 8098179 commit 26bc83b

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

fs/smb/client/smb1encrypt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <linux/fips.h>
1313
#include <crypto/md5.h>
14+
#include <crypto/utils.h>
1415
#include "cifsproto.h"
1516
#include "smb1proto.h"
1617
#include "cifs_debug.h"
@@ -131,7 +132,7 @@ int cifs_verify_signature(struct smb_rqst *rqst,
131132
/* cifs_dump_mem("what we think it should be: ",
132133
what_we_think_sig_should_be, 16); */
133134

134-
if (memcmp(server_response_sig, what_we_think_sig_should_be, 8))
135+
if (crypto_memneq(server_response_sig, what_we_think_sig_should_be, 8))
135136
return -EACCES;
136137
else
137138
return 0;

fs/smb/client/smb2transport.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/highmem.h>
2121
#include <crypto/aead.h>
2222
#include <crypto/sha2.h>
23+
#include <crypto/utils.h>
2324
#include "cifsglob.h"
2425
#include "cifsproto.h"
2526
#include "smb2proto.h"
@@ -617,7 +618,8 @@ smb2_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
617618
if (rc)
618619
return rc;
619620

620-
if (memcmp(server_response_sig, shdr->Signature, SMB2_SIGNATURE_SIZE)) {
621+
if (crypto_memneq(server_response_sig, shdr->Signature,
622+
SMB2_SIGNATURE_SIZE)) {
621623
cifs_dbg(VFS, "sign fail cmd 0x%x message id 0x%llx\n",
622624
shdr->Command, shdr->MessageId);
623625
return -EACCES;

0 commit comments

Comments
 (0)