mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:24:47 +01:00
net/tcp-ao: Fix MAC comparison to be constant-time
To prevent timing attacks, MACs need to be compared in constant
time. Use the appropriate helper function for this.
Fixes: 0a3a809089 ("net/tcp: Verify inbound TCP-AO signed segments")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
Link: https://patch.msgid.link/20260302203600.13561-1-ebiggers@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
2ffb4f5c2c
commit
67edfec516
2 changed files with 3 additions and 1 deletions
|
|
@ -748,6 +748,7 @@ config TCP_SIGPOOL
|
|||
config TCP_AO
|
||||
bool "TCP: Authentication Option (RFC5925)"
|
||||
select CRYPTO
|
||||
select CRYPTO_LIB_UTILS
|
||||
select TCP_SIGPOOL
|
||||
depends on 64BIT && IPV6 != m # seq-number extension needs WRITE_ONCE(u64)
|
||||
help
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#define pr_fmt(fmt) "TCP: " fmt
|
||||
|
||||
#include <crypto/hash.h>
|
||||
#include <crypto/utils.h>
|
||||
#include <linux/inetdevice.h>
|
||||
#include <linux/tcp.h>
|
||||
|
||||
|
|
@ -922,7 +923,7 @@ tcp_ao_verify_hash(const struct sock *sk, const struct sk_buff *skb,
|
|||
/* XXX: make it per-AF callback? */
|
||||
tcp_ao_hash_skb(family, hash_buf, key, sk, skb, traffic_key,
|
||||
(phash - (u8 *)th), sne);
|
||||
if (memcmp(phash, hash_buf, maclen)) {
|
||||
if (crypto_memneq(phash, hash_buf, maclen)) {
|
||||
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPAOBAD);
|
||||
atomic64_inc(&info->counters.pkt_bad);
|
||||
atomic64_inc(&key->pkt_bad);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue