Skip to content

Commit 8019b36

Browse files
Eric Biggersgregkh
authored andcommitted
sctp: Fix MAC comparison to be constant-time
commit dd91c79 upstream. To prevent timing attacks, MACs need to be compared in constant time. Use the appropriate helper function for this. Fixes: bbd0d59 ("[SCTP]: Implement the receive and verification of AUTH chunk") Fixes: 1da177e ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org> Link: https://patch.msgid.link/20250818205426.30222-3-ebiggers@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4fbcd2b commit 8019b36

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

net/sctp/sm_make_chunk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
3232

3333
#include <crypto/hash.h>
34+
#include <crypto/utils.h>
3435
#include <linux/types.h>
3536
#include <linux/kernel.h>
3637
#include <linux/ip.h>
@@ -1796,7 +1797,7 @@ struct sctp_association *sctp_unpack_cookie(
17961797
}
17971798
}
17981799

1799-
if (memcmp(digest, cookie->signature, SCTP_SIGNATURE_SIZE)) {
1800+
if (crypto_memneq(digest, cookie->signature, SCTP_SIGNATURE_SIZE)) {
18001801
*error = -SCTP_IERROR_BAD_SIG;
18011802
goto fail;
18021803
}

net/sctp/sm_statefuns.c

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

3131
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
3232

33+
#include <crypto/utils.h>
3334
#include <linux/types.h>
3435
#include <linux/kernel.h>
3536
#include <linux/ip.h>
@@ -4417,7 +4418,7 @@ static enum sctp_ierror sctp_sf_authenticate(
44174418
sh_key, GFP_ATOMIC);
44184419

44194420
/* Discard the packet if the digests do not match */
4420-
if (memcmp(save_digest, digest, sig_len)) {
4421+
if (crypto_memneq(save_digest, digest, sig_len)) {
44214422
kfree(save_digest);
44224423
return SCTP_IERROR_BAD_SIG;
44234424
}

0 commit comments

Comments
 (0)