* [PATCH] smb: client: Compare MACs in constant time
@ 2026-02-18 4:27 Eric Biggers
2026-03-03 5:04 ` Eric Biggers
2026-03-03 16:23 ` Paulo Alcantara
0 siblings, 2 replies; 4+ messages in thread
From: Eric Biggers @ 2026-02-18 4:27 UTC (permalink / raw)
To: Steve French, linux-cifs
Cc: samba-technical, linux-crypto, Paulo Alcantara, Ronnie Sahlberg,
Shyam Prasad N, Tom Talpey, Bharath SM, Eric Biggers, stable
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
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
fs/smb/client/smb1encrypt.c | 3 ++-
fs/smb/client/smb2transport.c | 4 +++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/smb/client/smb1encrypt.c b/fs/smb/client/smb1encrypt.c
index 0dbbce2431ff..bf10fdeeedca 100644
--- a/fs/smb/client/smb1encrypt.c
+++ b/fs/smb/client/smb1encrypt.c
@@ -9,10 +9,11 @@
*
*/
#include <linux/fips.h>
#include <crypto/md5.h>
+#include <crypto/utils.h>
#include "cifsproto.h"
#include "smb1proto.h"
#include "cifs_debug.h"
/*
@@ -129,11 +130,11 @@ int cifs_verify_signature(struct smb_rqst *rqst,
return rc;
/* cifs_dump_mem("what we think it should be: ",
what_we_think_sig_should_be, 16); */
- if (memcmp(server_response_sig, what_we_think_sig_should_be, 8))
+ if (crypto_memneq(server_response_sig, what_we_think_sig_should_be, 8))
return -EACCES;
else
return 0;
}
diff --git a/fs/smb/client/smb2transport.c b/fs/smb/client/smb2transport.c
index 8b9000a83181..81be2b226e26 100644
--- a/fs/smb/client/smb2transport.c
+++ b/fs/smb/client/smb2transport.c
@@ -18,10 +18,11 @@
#include <asm/processor.h>
#include <linux/mempool.h>
#include <linux/highmem.h>
#include <crypto/aead.h>
#include <crypto/sha2.h>
+#include <crypto/utils.h>
#include "cifsglob.h"
#include "cifsproto.h"
#include "smb2proto.h"
#include "cifs_debug.h"
#include "../common/smb2status.h"
@@ -615,11 +616,12 @@ smb2_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
rc = smb3_calc_signature(rqst, server, true);
if (rc)
return rc;
- if (memcmp(server_response_sig, shdr->Signature, SMB2_SIGNATURE_SIZE)) {
+ if (crypto_memneq(server_response_sig, shdr->Signature,
+ SMB2_SIGNATURE_SIZE)) {
cifs_dbg(VFS, "sign fail cmd 0x%x message id 0x%llx\n",
shdr->Command, shdr->MessageId);
return -EACCES;
} else
return 0;
base-commit: 2961f841b025fb234860bac26dfb7fa7cb0fb122
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] smb: client: Compare MACs in constant time
2026-02-18 4:27 [PATCH] smb: client: Compare MACs in constant time Eric Biggers
@ 2026-03-03 5:04 ` Eric Biggers
2026-03-03 16:23 ` Paulo Alcantara
1 sibling, 0 replies; 4+ messages in thread
From: Eric Biggers @ 2026-03-03 5:04 UTC (permalink / raw)
To: Steve French, linux-cifs
Cc: samba-technical, linux-crypto, Paulo Alcantara, Ronnie Sahlberg,
Shyam Prasad N, Tom Talpey, Bharath SM, stable
On Tue, Feb 17, 2026 at 08:27:02PM -0800, Eric Biggers wrote:
> 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
> Signed-off-by: Eric Biggers <ebiggers@kernel.org>
> ---
> fs/smb/client/smb1encrypt.c | 3 ++-
> fs/smb/client/smb2transport.c | 4 +++-
> 2 files changed, 5 insertions(+), 2 deletions(-)
Any feedback on this? Just to clarify, this is intended to be taken
through the smb tree.
- Eric
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] smb: client: Compare MACs in constant time
2026-02-18 4:27 [PATCH] smb: client: Compare MACs in constant time Eric Biggers
2026-03-03 5:04 ` Eric Biggers
@ 2026-03-03 16:23 ` Paulo Alcantara
2026-03-04 2:58 ` Steve French
1 sibling, 1 reply; 4+ messages in thread
From: Paulo Alcantara @ 2026-03-03 16:23 UTC (permalink / raw)
To: Eric Biggers, Steve French, linux-cifs
Cc: samba-technical, linux-crypto, Ronnie Sahlberg, Shyam Prasad N,
Tom Talpey, Bharath SM, Eric Biggers, stable
Eric Biggers <ebiggers@kernel.org> writes:
> 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
> Signed-off-by: Eric Biggers <ebiggers@kernel.org>
> ---
> fs/smb/client/smb1encrypt.c | 3 ++-
> fs/smb/client/smb2transport.c | 4 +++-
> 2 files changed, 5 insertions(+), 2 deletions(-)
Acked-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] smb: client: Compare MACs in constant time
2026-03-03 16:23 ` Paulo Alcantara
@ 2026-03-04 2:58 ` Steve French
0 siblings, 0 replies; 4+ messages in thread
From: Steve French @ 2026-03-04 2:58 UTC (permalink / raw)
To: Paulo Alcantara
Cc: Eric Biggers, Steve French, linux-cifs, Shyam Prasad N,
samba-technical, stable, Tom Talpey, Bharath SM, linux-crypto
merged into cifs-2.6.git for-next
On Tue, Mar 3, 2026 at 10:24 AM Paulo Alcantara via samba-technical
<samba-technical@lists.samba.org> wrote:
>
> Eric Biggers <ebiggers@kernel.org> writes:
>
> > 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
> > Signed-off-by: Eric Biggers <ebiggers@kernel.org>
> > ---
> > fs/smb/client/smb1encrypt.c | 3 ++-
> > fs/smb/client/smb2transport.c | 4 +++-
> > 2 files changed, 5 insertions(+), 2 deletions(-)
>
> Acked-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
>
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-04 2:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-18 4:27 [PATCH] smb: client: Compare MACs in constant time Eric Biggers
2026-03-03 5:04 ` Eric Biggers
2026-03-03 16:23 ` Paulo Alcantara
2026-03-04 2:58 ` Steve French
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox